Search code examples
gradlegradle-tomcat-plugin

Gradle dependency Is not loaded with gradle tomcat plugin


I have

compile 'org.slf4j:slf4j-jdk14:1.0'

in my dependencies, still getting

Caused by: java.lang.NoClassDefFoundError: org/slf4j/spi/LoggerFactoryBinder

when running

gradle clean tomcatRun

what is wrong with this tomcat class loader?


Solution

  • Has your tomcatRun task got a classpath from compile?

    configurations{
        tomcatRun 
    }
    
    dependecies{
         compile 'org.slf4j:slf4j-jdk14:1.0'
         tomcatRun configurations.compile
    }
    
    tomcatRun{
        classpath = configurations.tomcatRun 
    }