C
C
cyberorg2014-08-07 16:54:49
Java
cyberorg, 2014-08-07 16:54:49

How to get rid of dependency conflict in maven?

Situation:
Application A depends on two libraries B (version 1.4) and C (version 1.0.3). In turn, C also uses the B library (version 1.3).
There is no complete backward compatibility between versions 1.3 and 1.4.
Because of this, after the transition of application A to use library B version 1.4, the application began to crash at Runtime. The error occurs in the C library (swears that the required class is missing).
Two questions:
1) Why does library C use version 1.4 of library B, although it has version 1.3 in its pom.xml dependencies?
2) How, besides rolling back the version of library B to 1.3, fix application A?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanKiLL, 2014-08-07
@kyberorg

Maven Optional Dependencies and Dependency Exclusions
In general, this probably won't help you, you can try to deceive maven.
Do as it is written on the link that I gave, remove version 1.3

<dependency>
    <groupId>библиотека С</groupId>
    <artifactId>её имя</artifactId>
    <version>версия</version>
      <exclusions>
        <exclusion> 
          <groupId>библиотека</groupId>
          <artifactId>её id</artifactId>
        </exclusion>
</dependency>

Download version 1.3 and install it manually under a different groupId in the local repository, for example
mvn install:install-file -Dfile=toster.jar 
    -DgroupId=ru.toster -DartifactId=toster-api -Dversion=0.0.1 
    -Dpackaging=jar

and then add to pom
<dependency>
    <groupId>ru.toster</groupId>
    <artifactId>toster-api</artifactId>
    <version>0.0.1</version>
</dependency>

Then, in theory, both libraries will fall into the classpath.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question