Maven多模块项目:distribution模块无法打入其他模块依赖到Shaded Jar
解决Maven Shade插件无法打入依赖包的问题
问题根源
你的distribution模块中Maven Shade插件的artifactSet配置存在格式错误:对sentinel-java-wrapper的include规则写成了包路径dev.demeng.sentinel.wrapper,但Shade插件识别依赖需要遵循groupId:artifactId的格式,导致插件无法定位并打包该依赖。
修复方案
修改distribution模块pom.xml里Shade插件的artifactSet配置,将错误的include规则替换为正确的groupId:artifactId格式:
<artifactSet> <includes> <include>dev.nandi0813:InventoryArchiver-*</include> <!-- 修正依赖匹配规则 --> <include>dev.demeng:sentinel-java-wrapper</include> </includes> </artifactSet>
额外验证步骤
- 确认核心模块中
sentinel-java-wrapper依赖的scope是默认的compile(你的配置没问题,未设置provided/test等会阻断依赖传递的scope)。 - 执行
mvn dependency:tree命令检查distribution模块的依赖树,确认dev.demeng:sentinel-java-wrapper已被正确引入。 - 你的包重定位(relocation)配置是正确的,修正include规则后,Shade插件会正常将该依赖打入Jar并完成包路径重命名。
内容的提问来源于stack exchange,提问作者Nandor Dukat
相关产品推荐
相关产品推荐

