Spring Boot - Какой основной класс начать

Spring Boot - Какой основной класс начать

Если проект Spring Boot содержит несколько основных классов, Spring Boot не сможет запуститься или будет упакован для развертывания.

Терминал

$ 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]

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