SpringBoot项目本地运行正常,Maven打包报错:spring-boot-maven-plugin

不念不忘少年蓝@ 2023-10-04 20:31 99阅读 0赞

问题描述

SpringBoot项目本地运行正常,Maven打包报错:``Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed

  1. [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project SpringCloudUserFeign: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed: Unable to find main class -> [Help 1]
  2. [ERROR]
  3. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  4. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  5. [ERROR]
  6. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  7. ERROR http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
  8. Process finished with exit code 1

原因分析:

原因是添加该插件后编译打包时会自动寻找项目中的启动类,如果某个模块没有启动类或者有多个main启动类就会报错,通过保证模块启动类main启动类入口唯一也可以解决。


解决方案:

  1. <plugin>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-maven-plugin</artifactId>
  4. <configuration>
  5. <!-- spring boot启动类的路径 -->
  6. <mainClass>com.test.ApplicationMain</executable>
  7. </configuration>
  8. <executions>
  9. <execution>
  10. <goals>
  11. <goal>repackage</goal>
  12. </goals>
  13. </execution>
  14. </executions>
  15. </plugin>

发表评论

表情:
评论列表 (有 0 条评论,99人围观)

还没有评论,来说两句吧...

相关阅读