在我的项目的 pom.xml 中,我有以下依赖项:
<dependency>
<groupId>com.my.library</groupId>
<artifactId>MyLib</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
...
</dependency>
我想让我的项目最终构建的 jar 包含上述com.my.library:MyLib
依赖项的类,所以我以下列方式使用了maven-shade-plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.my.library:MyLib</artifact>
<includes>
<include>com/my/library/**</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
然后,我运行mvn clean install
,我的项目构建成功。
但是当我检查目录下 MyProject.jar 的内容时,它target/
不包含com.my.library:MyLib
依赖项中的类,为什么?我在哪里错了 maven-shade-plugin ?