문제

A maven project consisting of some modules. One of my module is using guava dependency of google version 11.0.2. Now i am integrating another module in my project which is also using guava but version 14.

So i want that new module uses guava version 14 but remaining project use guava version 11.0.2. I have tried adding <exclusion></exclusion> of guava to the new module but it didn't work.

Any tips to solve this.

Update: @Guillaume Darmont's Answer solves the problem for different modules. but now my problem is, the new modules has 2 dependency one of the them is using guava 11.0.2 and other is using 14.0. how to manage this. can we specify separately in the pom of the module that which version of the guava it should use.?

도움이 되었습니까?

해결책

As I understand your question, you may add a <dependencyManagement> for guava in your new module pom.xml :

<dependencyManagement>
  <dependencies>
      <dependency>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
          <version>14.0.1</version>
      </dependency>
  </dependencies>
</dependencyManagement>

다른 팁

mvn dependency:tree command will help to determine which module is bringing the Guava 14 jar file.

Firstly try mvn dependency tree and check the output it is possible that 11.0.2 has been transitively referenced from more than one of your projects dependencies and you will need to add exclusion to all the dependencies directly / indirectly pulling down the specific guava version you are trying to exclude.

Secondly resolving this conflict may not be straight forward. Looking at version number transition (11 to 14) sounds to me like a major transition, and you may have better chances keeping the 14 version and excluding the 11 something.

If the version change is not compatible with your application, you have pretty much no option but to use something like OSGi to ensure you can run different versions of same library in the project.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top