When my spring-boot code is executed, I get the error as below:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.2.RELEASE:run (default-cli) on project projectName: Unable to find a suitable main class, please add a 'mainClass' property
How can I solve this?
Add a mainclass to the plugin configuration
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>your.class.with.main.Method</mainClass>
</configuration>
</plugin>
...
</plugins>
...
</build>
Source: https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.