I\'ve generated a Spring Boot web application using Spring Initializer, embedded Tomcat, Thymeleaf template engine.Technologies used: Spring Boot 1.4.2.RELEASE, Spring 4.3.4
To disambiguate the entry point of a spring boot application, you can add the following directive to your Gradle build file
springBoot {
mainClassName = 'your.org.bla.TestKt'
}
or simply hard code the main class in plugin configuration.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>your.main.class.MainClass</mainClass>
</configuration>
</execution>
</executions>
</plugin>
Sometimes this error is given when you do mvn install without doing mvn clean.
I was building a spring boot library project, so I don't need a main starter class, so I faced the same issue while building the project with maven, so I removed the maven plugin to compile successfully
<!--
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
-->
For a more detailed example. find it here https://spring.io/guides/gs/multi-module/
Define single main class via start-class property
<properties>
<start-class>com.may.Application</start-class>
</properties>
Alternatively, define the main class in the spring-boot-maven-plugin
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.may.Application</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Or via profiles
<profiles>
<profile>
<id>profile1</id>
<properties>
<spring.boot.mainclass>com.may.Application1</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>profile2</id>
<properties>
<spring.boot.mainclass>com.may.Application2</spring.boot.mainclass>
</properties>
</profile>
<profiles>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>${spring.boot.mainclass}</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>