You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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>

额外验证步骤

  1. 确认核心模块中sentinel-java-wrapper依赖的scope是默认的compile(你的配置没问题,未设置provided/test等会阻断依赖传递的scope)。
  2. 执行mvn dependency:tree命令检查distribution模块的依赖树,确认dev.demeng:sentinel-java-wrapper已被正确引入。
  3. 你的包重定位(relocation)配置是正确的,修正include规则后,Shade插件会正常将该依赖打入Jar并完成包路径重命名。

内容的提问来源于stack exchange,提问作者Nandor Dukat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 13:24:53