Maven - Different Dependency Version in Test

前端 未结 2 1224
清歌不尽
清歌不尽 2021-01-25 11:19

I\'m suffering an issue similar to Maven 2 - different dependency versions in test and compile but the specified answer there does not work.

In my project I need to depe

2条回答
  •  被撕碎了的回忆
    2021-01-25 11:52

    What you desire, is no longer valid for Maven 3 (this used to be valid for Maven 2). Maven 3 will attempt to obtain the nearest dependency, effectively ensuring that only one of the compile or test scoped dependency is used for both the compile and test phases.

    In your case org.apache.hadoop:hadoop-core:1.0.0:test overrides org.apache.hadoop:hadoop-core:0.20.2-cdh3u2:compile and hence becomes the nearest dependency. You may see the following warning displayed by Maven when running the mvn dependency:list goal, that alludes to this being a problem in your project model:

    [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.hadoop:hadoop-core:jar -> version 0.20.2-cdh3u2 vs 1.0.0 @ line xyz, column xyz

    To 'fix' this, it would be better to split your tests into a separate project whose project model can define a separate set of test dependencies.

提交回复
热议问题