我有编译和运行时所需的依赖项,但我想在运行测试时排除它。这可能吗?也许,通过设置个人资料?但我如何仅停用它test
生命周期阶段?
您可以在测试阶段(重新)配置类路径,这要归功于Maven Surefire 插件 http://maven.apache.org/plugins/maven-surefire-plugin/examples/configuring-classpath.html。您可以添加类路径元素或排除依赖项。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
<additionalClasspathElement>path/to/additional/jar</additionalClasspathElement>
</additionalClasspathElements>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.apache.commons:commons-email</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
As noted https://stackoverflow.com/questions/12053316/exclude-maven-dependency-for-tests/12068045#comment16347219_12068045通过 @jFrenetic 你可以做同样的事情maven-failsafe-插件 http://maven.apache.org/surefire/maven-failsafe-plugin/examples/configuring-classpath.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)