我想排除僅用於測試範圍的依賴項。如何排除僅用於java中測試範圍的依賴項
例子: -
公地lang3關係在我的項目中兩個不同的地方使用。我想只爲測試範圍排除這種依賴關係。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
我該怎麼做?
我想排除僅用於測試範圍的依賴項。如何排除僅用於java中測試範圍的依賴項
例子: -
公地lang3關係在我的項目中兩個不同的地方使用。我想只爲測試範圍排除這種依賴關係。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
我該怎麼做?
您可以在surefire插件上配置classpath
。 象下面這樣:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>xxx</version>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.apache.commons:commons-lang3</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
這不就是排除commons-lang3依賴關係而不考慮構建範圍嗎? –
@ 911DidBush surefire插件僅在測試範圍內發揮作用,因此它僅在測試範圍內排除commons-lang3依賴項。 –
爲什麼?這個庫在測試中有什麼危害? – 2016-12-16 12:58:33
@Lutz Horn我有我的自定義依賴關係,我只想排除測試 – karan