gpt4 book ai didi

java - maven:包括单个 jar 的选定依赖项

转载 作者:太空宇宙 更新时间:2023-11-04 06:49:29 25 4
gpt4 key购买 nike

我有一个 maven 模块,它依赖于另外两个模块

   <dependencies>
<dependency>
<groupId>com.org.me_services.federated_services</groupId>
<artifactId>ifs</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.org.me_services.inventory</groupId>
<artifactId>converter</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

我希望这两个依赖项都包含在该模块创建的 jar 中。我尝试了 maven shade 插件,例如

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<finalName>business-${artifactId}-${version}</finalName>
</configuration>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>

但是这捆绑了所有依赖项(甚至是框架)。有没有办法选择我想要包含在最终 jar 中的依赖项?

最佳答案

您可以指定排除阴影伪影:

http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_dependencySet

  <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>
<artifactSet>
<excludes>
<exclude>classworlds:classworlds</exclude>
<exclude>junit:junit</exclude>
<exclude>jmock:*</exclude>
<exclude>*:xml-apis</exclude>
<exclude>org.apache.maven:lib:tests</exclude>
<exclude>log4j:log4j:jar:</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>

关于java - maven:包括单个 jar 的选定依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23532681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com