Spring Boot - Quelle classe principale commencer?

Spring Boot - Quelle classe principale commencer

Si le projet Spring Boot contient plusieurs classes principales, Spring Boot ne démarre pas ou n'emballe pas pour le déploiement.

Terminal

$ mvn package
#or
$ 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.example.Test, com.example.SpringBootWebApplication] -> [Help 1]

Exemple Maven

1.1 Define single main class via start-class properties

pom.xml

  
      
      com.example.SpringBootWebApplication
  

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

pom.xml

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    com.example.SpringBootWebApplication