在用Maven build 工程时, 有些依赖的jar打不到安装包中去,试来拭去,最后发现问题所在:
例如:我的顶层jar是a, a 依赖 b, c, d,
我在assembly的pom中,添加了依赖a, b, c, d
如下:
<dependencies>
<dependency>
<groupId>myapp</groupId>
<artifactId>a</artifactId>
<version>1.1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myapp</groupId>
<artifactId>b</artifactId>
<version>1.1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myapp</groupId>
<artifactId>c</artifactId>
<version>1.1.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>myapp</groupId>
<artifactId>d</artifactId>
<version>1.1.1</version>
<type>jar</type>
</dependency>
</dependencies>
然后再assembly的descriptor中打包时,只写a, 如下
<dependencySets>
<dependencySet>
<outputDirectory>app/lib</outputDirectory>
<useTransitiveFiltering>true</useTransitiveFiltering>
<includes>
<include>
myapp:a
</include>
</dependencySet>
</dependencySets>
结果,只有a 打进了程序包中。b, c, d及其传递的依赖都没有打进去。
后来我把 b, c, d的依赖从pom中移走,
这次,a, b, c, d都打进了应用包