【发布时间】:2018-08-23 23:53:54
【问题描述】:
在我的pom.xml 我有以下<plugin> 部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludes>META-INF/*.SF</excludes>
<excludes>META-INF/*.DSA</excludes>
<excludes>META-INF/*.RSA</excludes>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes/lib/</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
但是,每当我使用mvn clean install -U 构建项目时,都会将一些 .SF、.DSA 和 .RSA 复制到构建的 jar 文件中,我需要手动删除它们。
如何解决这个问题?
【问题讨论】:
-
不排除依赖项内的文件,而是排除依赖项。 -
您拥有的
copy-dependencies目标...复制依赖项。它不会从任何地方删除任何文件。你想要的可能是Shade插件,见*.com/questions/17658831/… -
@Tunaki excludes 将在复制时从依赖项中删除这些文件