maven - Override a dependency of a dependency -


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

Next to this, I have two projects, C-6 and C7, the I-6 project is compiled in Java 6, while the C7 is compiled in Java 7.

Project B has the dependence of C project. By default, in reference to Project B reference C-7, which means it uses Java 7 version of Project C. There are many different projects referenced in Project B and they are compiled in Java 7, so there is no problem here.

But now I have my project, which has been compiled in Java 6. Now I want to override the dependency of my dependency b. The problem is that when I exclude C7 in Project A and add dependence to C6, then I say that in a project B, it will get a class from C7, so my app is crashing Because it is not compatible.

How do I solve it? How can I tell my dependency B to use a different dependency C, it usually depends? Please keep in mind that many projects use Project B as dependency, so I do not like to change anything, including changing other projects.

Within a given dependency, you exclude exclusions Tags. If you then add a corresponding dependency to your project, then this library will be on your classpath, which will be instead of the dependency taken out. We use this feature all the time to swap the logging library. However, this technique is of limited value, as you have inserted the library that you have to implement the same interface, because the library you are taking Like I said, it works well for logging, but most of the other things are not very good.

This will look something like this:

  & lt; Dependency & gt; & Lt; Group & gt; Com.my.company & lt; / Group & gt; & Lt; ArtifactId & gt; B & lt; / ArtifactId> & Lt; Exclusions & gt; & Lt; Exclusion & gt; C7 & lt; / Exclusion & gt; & Lt; / Exclusions & gt; & Lt; / Dependencies & gt; & Lt; Dependency & gt; & Lt; Group & gt; Com.my.company & lt; / Group & gt; & Lt; ArtifactId & gt; C6 & lt; / ArtifactId> & Lt; / Dependencies & gt;  

Comments