按照【7-6 Servlet 异步支持】的讲解,打包spring-servlet模块时,出现【Unable to find main class 】错误

来源:7-6 Servlet 异步支持

小武藏

2018-10-16

具体情况:
按照【7-6 Servlet 异步支持】的讲解,打包spring-servlet模块时,
因为没有主类,执行mvn打包出现【Unable to find main class 】错误。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.746 s
[INFO] Finished at: 2018-10-16T11:13:32+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:repackage (default) on project spring-servlet: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:repackage failed: Unable to find main class -> [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/PluginExecutionException

⚠️使用老师提供的spring-servlet源码,也出现同样错误。

后续调查:
在网上找资料,解决办法是【去掉主工程中的spring-boot-maven-plugin】,错误解决了,但是工程启动时,并没有当成springboot的工程,所以还是不好用。

麻烦老师给回答一下,谢谢!

写回答

1回答

小马哥

2018-10-16

可以选择把当前工程的 parent 移除,然后逐一添加依赖。

0
0

Spring Boot2.0深度实践 核心原理拆解+源码分析

系统化剖析Spring Boot 2.0,掌握技术原理,学习源码阅读技巧

2904 学习 · 213 问题

查看课程