1. Overview

When Spring boot application contains multiple main class at that time exception will be thrown at time of compilation because spring boot will get confused from which main should start application, If application contains single main class there nothing to worries but if multiple main class then we should provide explicitly at time of compilation from which class application should start. Here is different ways to provide main class in spring boot application:

Exception: Spring boot Unable to find a single main class from the following candidates

While compiling spring boot application and throwing exception when application have more then one class with public static void main(String[] args) methods.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) on project spring-boot-example: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.4.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.javadeveloperzone.SpringBootConfig, com.javadeveloperzone.SpringBootConfig1] -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Solution 1 – mainClass in spring boot maven plugin:

add mainClass in spring-boot-maven-plugin's a configuration as like:



Solution 2: add start-class in maven properties

Inside the pom.xml write bellow configuration in which <start-class> contains name of the class file which will be consider as main class of spring boot application.




Spring boot jar/war package document


Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *