Gradle – Exclude commons-logging from Spring

Gradle example to exclude commons-logging from Spring frameworks.

build.gradle

    compile('org.springframework:spring-webmvc:4.2.4.RELEASE'){
        exclude group: 'commons-logging', module: 'commons-logging'
    }

If you have multiple Spring dependencies, you have to exclude for each

build.gradle

    compile('org.springframework:spring-webmvc:4.2.4.RELEASE'){
        exclude group: 'commons-logging', module: 'commons-logging'
    }

    compile('org.springframework:spring-test:4.2.4.RELEASE'){
        exclude group: 'commons-logging', module: 'commons-logging'
    }

A better solution is excluding commons-logging at the project level.

build.gradle

	configurations.all {
	    exclude group: "commons-logging", module: "commons-logging"
	}

    compile 'org.springframework:spring-webmvc:4.2.4.RELEASE'
    compile 'org.springframework:spring-test:4.2.4.RELEASE'

References

  1. Spring MVC + Logback SLF4j example
  2. Gradle – Display project dependency

2 comments on “Gradle – Exclude commons-logging from Spring

  1. Keeps telling me exclude is an unrecognized symbol. Using gradle 3.3

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *