我试图通过编辑 pom.xml 排除 jar 中的包(maven 依赖项)
所以我尝试了一些在 中添加标签、使用 maven-shade-plugin 和使用 maven-jar-plugin 的方法。 但这没有用。 jar 中的包仍然存在。
这是我尝试过的代码。谢谢。 artifact是jar名称,com.domain.package是删除表单jar的包。
<!-- first trial -->
<dependencies>
<dependency>
<groupId>Group</groupId>
<artifactId>artifact</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/artifact.jar</systemPath>
<exclusions>
<exclusion>
<groupId>com.domain.package</groupId>
<artifactId>package</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- second trial -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>artifact:com.domain.package</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<!-- third trial -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>artifact</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludes>
<exclude>**/com/domain/package/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
最佳答案
您可以在 Maven jar 插件执行中定义配置以排除和包含文件。
<configuration>
<includes>
<include>**/service/*</include>
</includes>
https://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html
关于java - 如何通过编辑pom.xml来排除jar中的包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55333969/