目录
记一个springboot打包出错的踩坑记录:
一, 现象
报错内容类似如下:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE:repackage (default) on project shipWireMaster: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE:repackage failed: A required class was missing while executing org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE:repackge org.springframework.util.StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
二,分析过程
1.原先打包正常,在内网对接自动化打包需要调整pom文件,对一些组件的版本进行了升级调整,所依赖的版本且都是内网maven库已经存在的,从代码依赖来看,没有直接缺包的错误;
2. 切换到本地老的maven仓库,打包正常,创建新仓库,依赖的jar全部从线上下载,打包存在问题,推测是是哪里不兼容。但是无法确定具体不兼容位置;
3. 根据错误中plexus的出现,猜想是不是这个包间接有一些依赖,线上仓库的不全?将原maven库org.codehaus下的所有包都拷贝到新的仓库,打包依然出现错误;排除了plexus包下载不全的推测,真正的问题所以与直接报错提示可能关系不大,继续寻找原因。
4. 既然推测到是哪里不兼容,再大胆一些,是不是遇到冷门bug,网上百度搜索没有看到有效的解决方案;上谷姐根据核心报错信息 org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy搜索,根据相关性排名,把前面几页的链接都打开,看到类似的报错,是maven打包插件与springBoot的兼容确实存在问题。遂修改repackage using spring-boot-maven-plugin 2.0.0;
三,解决方式
在pom的打包配置处,在repackage的时候,采用spring-boot-maven-plugin 2.0.0,原先项目使用的是1.5.7。重新打包,成功。
参考链接:https://github.com/spring-projects/spring-boot/issues/10559
同时发现了一位提出解决方案的大佬:https://github.com/philwebb
版权声明:本文为weixin_39734304原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。