Ste*_*eve 34 maven-2 dependency-management pom.xml maven
我在我的POM中有一个依赖项需要设置为"提供",因此它不包含在编译中,但它仍然可以在我的项目中引用.当我去运行测试时,我希望相同的依赖项具有"test"范围,因此我不必手动将jar添加到我的类路径中.有没有办法做到这一点或取得类似的结果?
这背后的推理是我在JBOSS lib目录中提供了一些常见的jar,所以我想使用它们并保持它们的"提供"范围用于构建的战争.但是,当我从命令行运行JUnits时,我想使用存储库中的jar而不是手动将其添加到我的类路径中.
提前致谢
您可以使用将这些依赖项声明为测试或提供的配置文件 - 具体取决于您更方便的内容:
<profiles>
<profile>
<id>whatever</id>
<activation>
<property>
<name>env</name>
<value>whatever</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>yours</groupId>
<artifactId>yours</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>test</id>
<activation>
<property>
<name>env</name>
<value>test</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>yours</groupId>
<artifactId>yours</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
通过设置属性env激活这些配置文件,但还有其他方法,默认激活 - 看看这里.
归档时间: |
|
查看次数: |
18907 次 |
最近记录: |