Xeo*_*eon 12 java maven-2 versions maven
我的项目依赖于commons-httpclient [2.0](编译).
我想写一些jbehave测试 - jbehave-core 3.4.5(测试).这两个依赖项都依赖于commons-lang,但是在不同的版本中 - 1.0.1和2.5.
当我执行mvn包时,我在测试部分得到[BUID FAILURE].在surefire-plugin输出中我的测试用例有一个例外:
java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.substringBeforeLast(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
Run Code Online (Sandbox Code Playgroud)
当我查看源代码时 - 在commons-lang 1.0.1中 - 实际上,没有StringUtils.substringBeforeLast(...)方法.为什么maven在commons-httpclient(编译)中使用commons-lang而在测试中不使用jbehave-core?
我不能在commons-httpclient中排除这个冲突的依赖,所以它必须保持编译时间.
那么如何解决这个问题呢? - 测试中的commons-lang 2.5版本和编译时的1.0.1版本.
尝试定义<dependency>
具有不同版本和范围的2个不同标签.<scope>test</scope>
在依赖项中使用标记进行测试和<scope>compile</scope>
编译.