[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.3.2:run (default-cli) on project initializr: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
请帮我解决这个问题。
在 pom 的构建部分中,您需要包含 spring-boot-plugin 并定义主类。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.yourpackage.YourMainApplicationClassName</mainClass>
</configuration>
</plugin>
</plugins>
</build>
所以,如果我的主应用程序类是
MainClass
包中的 com.acme
,我会将 mainClass 属性设置为 com.acme.MainClass