jenkins用spring-boot-maven-plugin构建出错:repackage failed: Unable to find main class
完整的报错信息如下:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project mfsms-updatereceipt: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :mfsms-updatereceipt
主要是Unable to find main class,找不到主类,也就是启动类
首先是我根据问题查询来的答案:
https://www.cnblogs.com/thinking-better/p/7827368.html
可以通过在pom.xml中指定mainclass来使得构建成功
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.xx.MyappApplication</mainClass></configuration>
</plugin>
说是多个@SpringBootApplication注解会导致主类冲突,或者在没有该启动类注解的情况下有多个public static void main。我并没有这种情况,在指定mainclass后可以成功构建,但是生成的jar包无法执行,显示
Exception in thread “main” java.lang.ClassNotFoundException: com.xx.MyappApplication
于是又鼓捣半天后也还是不能成功打包+执行
后面仔细查看jenkins的报错
[INFO] — maven-resources-plugin:3.0.2:resources (default-resources) @ mfsms-updatereceipt —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/MFSMS-updatereceipt/mfsms-updatereceipt/src/main/resources
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/MFSMS-updatereceipt/mfsms-updatereceipt/src/main/resources
[INFO]
[INFO] — maven-compiler-plugin:3.7.0:compile (default-compile) @ mfsms-updatereceipt —
[INFO] No sources to compile
[INFO]
这里显示compile编译下找不到东西,resouce也找不到
后面仔细对比路径后发现 src/main写成了src/mian
看来spring-boot-maven插件构建时默认找的是pom.xml所在路径下的src/main文件夹,名字拼错和类似web/src/main的嵌套文件夹都会出现这样的错误。当然也可以在pom文件里指定路径来解决。
因此如果你也出现了和我一样的问题,百度其他方法无效,不妨先
检查一下启动类src/main的路径是否填写正确,是否不存在嵌套文件夹的情况
jenkins用spring-boot-maven-plugin构建出错:repackage failed: Unable to find main class相关推荐
- maven打包repackage failed: Unable to find main class
一.Maven打包Spring Boot项目报错(repackage failed: Unable to find main class),排除寻找Main方法,一般用于被依赖的公用常量模块,解决方法 ...
- Idea Spring Boot项目提示 repackage failed: Unable to find main class
本人项目是一个多模块的Spring Boot项目,模块打包时一直显示没有找到主类,很奇怪,我项目中其它的模块都可以正常打包 报错内容: Failed to execute goal org.sprin ...
- maven package异常repackage failed: Unable to find main class
现象 模块package时出现异常 Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.1:rep ...
- Spring Boot的Maven插件Spring Boot Maven plugin详解
pring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Maven ...
- org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
警告]"build.plugins.plugin.version"for org.springframework.boot:spring boot maven plugin丢失. ...
- maven打包插件----Spring Boot Maven Plugin
官方文档链接地址:http://docs.spring.io/spring-boot/docs/1.3.0.BUILD-SNAPSHOT/maven-plugin/index.html 第一部分 Sp ...
- maven testNG打成jar包运行报错repackage failed: Unable to find main class
一.maven testNG如何打jar包 1.pom文件引入插件 <build><plugins><plugin><groupId>org.apach ...
- Maven打包问题:repackage failed: Unable to rename解决
今天在给spring boot项目打jar包的时候遇到了一个问题: Failed to execute goal org.springframework.boot:spring-boot-maven- ...
- 【异常】Maven构建报错 repackage failed: Unable to find a single main class from the following candidates
一.报错内容 Failed to execute goal org.springframework.boot: spring-boot-maven-plugin:2.6.11:repackage (r ...
最新文章
- transform css3 的使用及理解
- 三十一、Scrapy爬取百度图片
- 10 | 案例篇:系统的软中断CPU使用率升高,我该怎么办?
- servlet 配置 使用_配置HTTPS以与Servlet一起使用
- 笔记本电脑锁_2020年双11有哪些值得选购的笔记本电脑?(全能本/便携高性能笔记本电脑/设计本)...
- __property 关键字的使用
- 新冠肺炎疫情数学模型的一点想法
- [渝粤教育] 西南科技大学 交通工程学 在线考试复习资料
- 小蜜蜂(动态规划dp)
- MSDN2008中文版下载地址
- 微信api接口调用-给微信好友或群聊发消息
- 大厂年薪几十万,但是5-8年外包程序员,年薪是多少你知道吗?
- (6.0系统)安卓神器XPOSED框架无需ROOT安装指南
- OSChina 周五乱弹 —— 姑娘在这个节日里表白你接受么?
- 泰克示波器TBS2000B 在大学基础实验室的应用
- Linux系统磁盘高级应用适合初学者
- 电磁兼容测试在测试带载电机控制系统的方法
- javascript实现简单拖曳功能
- Tomcat 7 相关参数优化说明及配置最佳案例
- 在Jupyter notebook中加入虚拟环境kernal