If Spring Boot project contains multiple main classes, Spring Boot will fail to start or packag for deployment.


$ mvn package 
$ mvn spring-boot:run

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) 
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run failed: 
Unable to find a single main class from the following candidates 
 [com.mkyong.Test, com.mkyong.SpringBootWebApplication] -> [Help 1]

Maven example

1.1 Define single main class via start-class properties


      <!-- The main class to start by executing java -jar -->

1.2 Alternatively, define the main class in the spring-boot-maven-plugin




  1. Spring Boot – The executable jar format
  2. Spring Boot Maven Plugin – Usage