Pregunta

I am working on porting some legacy code to a new versions . one particular module (slf4j) in which 1.5x versions are incompatible with 1.6x and 1.7x , my problem is a project that my project depends on is included as an jar in the classpath . Is there a way to get around such a problem ?

¿Fue útil?

Solución

If there is a direct dependency in pom Maven will use it and omit any transitive dependencies to the same artifact, eg here

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>2.12.1</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>

camel-core has a transitive dependency slf4j-api-1.6.6 but Maven will choose slf4j-api-1.7.5

Otros consejos

The way I solved my issue is to redeploy the project that my project depended on . Since it was a jar I had to recreate it in a maven format and add the necessary exclusion statements to stop all transitive dependencies at that level . This may not be best practice but worked in my case . I guess with the newer version of projects being all maven based exclude tags should be enough

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top