Override dependency dependency

I have a project A that is compiled in Java 6. It depends on project B, which is also compiled in Java 6.

Next to them, I have two projects: C-6 and C-7. C-6 is a C project compiled in Java 6, and C-7 compiled in Java 7.

Project B has a dependency on project C. By default, project B refers to project C-7, that is, it uses the version of the Java 7 C project. There are many projects related to project B, and they are all compiled in Java 7, so there is no problem .

But now I have my project A, which is compiled in Java 6. Now I would like to redefine the dependency of my dependency B. The problem is that even when I exclude C-7 in project A and add the dependency to C-6, as soon as I will call a method in project B, it will receive a class from C-7. Thus, my application crashes because it is incompatible.

How can i solve this? How can I say that my dependency B uses a different dependency C, what does it usually depend on? Keep in mind that many projects use project B as a dependency, so I prefer not to change anything due to the need to change other projects.

+3
source share
1 answer

exclusions . , , . . , , , , , . , , .

:

<dependency>
    <groupId>com.my.company</groupId>
    <artifactId>B</artifactId>
    <exclusions>
        <exclusion>C7</exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.my.company</groupId>
    <artifactId>C6</artifactId>
</dependency>
0

All Articles