gpt4 book ai didi

java - 如何从依赖 war 中排除jar,仅用于在pom中运行测试

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

抱歉,如果这个问题很简单,我尝试了很多,但无法找到解决方案。

我有一个项目A。在这个war项目的pom.xml中,我有一个依赖项目,我将其添加为pom.xml中的依赖项。到目前为止一切都很好。

这是我在父项目项目 A 的 pom.xml 中执行此操作的方法:

 <dependency>
<groupId>com.abc.rules</groupId>
<artifactId>rules-common</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>

运行构建后功能运行良好

但是当我尝试运行父项目项目 A 的测试用例时,它不起作用。

然后我在 pom.xml 中尝试了这个,它起作用了:

       <dependency>
<groupId>com.abc.rules</groupId>
<artifactId>rules-common</artifactId>
<version>0.0.2-SNAPSHOT</version>
-<exclusions>
-<exclusion> <groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guava</artifactId>
</exclusion>
</exclusions>
</dependency>

但我可能会影响我的功能。

所以我需要的是,我需要排除 sisu-guava.jar 来运行我的父项目项目 A 的测试用例。但它不应该像我上面所做的那样被排除。

而且我无法对 rules-common war 项目的 pom.xml 进行任何更改。如何在项目A的pom.xml中进行相关更改?

谁能帮帮我。

最佳答案

尝试将其添加到您的 pom 中

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.abc.rules</groupId>
<artifactId>rules-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

或者在某些情况下您将不得不使用配置文件来排除依赖项

关于java - 如何从依赖 war 中排除jar,仅用于在pom中运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39491282/

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