Quan Ding
Quan Ding

Reputation: 727

Gradle dependency exclusion not working for transitive dependency

I got the following Exception when I tried to start the server:

Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class

Some stackoverflow post suggests that I have conflict versions of spring-asm in my classpath. Through gradle dependency analysis, I see that I don't have multiple versions of spring-asm, but I do have multiple versions of spring-core (version 3.1.4 and 5.0.2)

org.springframework:spring-core:5.0.2.RELEASE (conflict resolution)
+--- runtime
...
+--- project :foundation-util
...
org.springframework:spring-core:3.1.4.RELEASE -> 5.0.2.RELEASE
+--- com.abc:adcontentserviceclient:1801
|    +--- project :domain-cs-bl
|    |    +--- runtime
...

I tried to exclude version 3.1.4 but couldn't get it working. I tried to exclude it both at the dependency level and the configuration level.

configurations {
    all*.exclude group: 'spring-framework', module: 'spring-core'
}

dependencies {

compile(group: 'com.abc, name: 'adcontentserviceclient', version: "${adCsVersion}", changing: true) {
    exclude group: 'org.springframework', module: 'spring-core'
}

Even with the above changes, I still find spring-core:3.1.4.RELEASE in dependency analysis output.

Upvotes: 2

Views: 1670

Answers (1)

tkruse
tkruse

Reputation: 10695

The output

org.springframework:spring-core:3.1.4.RELEASE -> 5.0.2.RELEASE

means that while 3.1.4.RELEASE is required somewhere, gradle is actually using 5.0.2.RELEASE to satisfy that. So no need for you to exclude 3.1.4.RELEASE. Your problem lies elsewhere.

You could still exclude 3.1.4.RELEASE, but the details you give in your question are not sufficient to tell you why it's not working.

Upvotes: 1

Related Questions