完整的报错信息如下:
[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相关推荐

  1. maven打包repackage failed: Unable to find main class

    一.Maven打包Spring Boot项目报错(repackage failed: Unable to find main class),排除寻找Main方法,一般用于被依赖的公用常量模块,解决方法 ...

  2. Idea Spring Boot项目提示 repackage failed: Unable to find main class

    本人项目是一个多模块的Spring Boot项目,模块打包时一直显示没有找到主类,很奇怪,我项目中其它的模块都可以正常打包 报错内容: Failed to execute goal org.sprin ...

  3. 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 ...

  4. Spring Boot的Maven插件Spring Boot Maven plugin详解

    pring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Maven ...

  5. org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012

    警告]"build.plugins.plugin.version"for org.springframework.boot:spring boot maven plugin丢失. ...

  6. maven打包插件----Spring Boot Maven Plugin

    官方文档链接地址:http://docs.spring.io/spring-boot/docs/1.3.0.BUILD-SNAPSHOT/maven-plugin/index.html 第一部分 Sp ...

  7. maven testNG打成jar包运行报错repackage failed: Unable to find main class

    一.maven testNG如何打jar包 1.pom文件引入插件 <build><plugins><plugin><groupId>org.apach ...

  8. Maven打包问题:repackage failed: Unable to rename解决

    今天在给spring boot项目打jar包的时候遇到了一个问题: Failed to execute goal org.springframework.boot:spring-boot-maven- ...

  9. 【异常】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 ...

最新文章

  1. transform css3 的使用及理解
  2. 三十一、Scrapy爬取百度图片
  3. 10 | 案例篇:系统的软中断CPU使用率升高,我该怎么办?
  4. servlet 配置 使用_配置HTTPS以与Servlet一起使用
  5. 笔记本电脑锁_2020年双11有哪些值得选购的笔记本电脑?(全能本/便携高性能笔记本电脑/设计本)...
  6. __property 关键字的使用
  7. 新冠肺炎疫情数学模型的一点想法
  8. [渝粤教育] 西南科技大学 交通工程学 在线考试复习资料
  9. 小蜜蜂(动态规划dp)
  10. MSDN2008中文版下载地址
  11. 微信api接口调用-给微信好友或群聊发消息
  12. 大厂年薪几十万,但是5-8年外包程序员,年薪是多少你知道吗?
  13. (6.0系统)安卓神器XPOSED框架无需ROOT安装指南
  14. OSChina 周五乱弹 —— 姑娘在这个节日里表白你接受么?
  15. 泰克示波器TBS2000B 在大学基础实验室的应用
  16. Linux系统磁盘高级应用适合初学者
  17. 电磁兼容测试在测试带载电机控制系统的方法
  18. javascript实现简单拖曳功能
  19. Tomcat 7 相关参数优化说明及配置最佳案例
  20. 在Jupyter notebook中加入虚拟环境kernal

热门文章

  1. Ubuntu查看网卡信息
  2. [DASCTF 7月赛] 复现
  3. 高考报志愿选什么专业?
  4. nodejs基于RabbitMq的RPC调用
  5. 《分析一波NBA今年季后赛之听说东部今年格外牛?》
  6. springboot研究九:lettuce连接池很香,撸撸它的源代码
  7. python文件转换成exe和apk文件
  8. IPv6+:构筑云网基石,共倡智联未来
  9. iPhone开发——加入程序图标
  10. JAVA打印流PrintStream 常用方式