cannot compile spring-security-core because of ehc

2019-06-27 13:17发布

问题:

I'm trying to add spring-security to my grail project but it fails at compilation. Here are the plugins i have in BuildConfig.groovy: ` // plugins for the build system only build ":tomcat:7.0.54"

    // plugins for the compile step
    compile ":scaffolding:2.1.1"
    compile ':cache:1.1.6'
    compile ":asset-pipeline:1.8.11"
    compile ":mongodb:3.0.1"
    compile ":spring-security-core:2.0-RC3"


    // plugins needed at runtime but not for compilation
    //runtime ":hibernate4:4.3.5.4" // or ":hibernate:3.6.10.16"
    runtime ":jquery:1.11.1"`

The compilation failed, I got this fatal error message:

Fatal error during compilation java.lang.NoClassDefFoundError: net/sf/ehcache/config/CacheConfiguration

I followed the instructions here but get stuck after the 'grails compile' step. I tried adding ehcache dependency in the plugins list but then it says that it couldn't be downloaded. I don't know what to do. The project is very simple, I've just beginning the tutorial from the link I gave before. I just uninstalled hibernate and installed mongodb instead.

回答1:

You should add ehcache to the dependencies not plugins.

dependencies {
    compile "net.sf.ehcache:ehcache-core:2.4.8"
}

I don't think spring-security-core needs hibernate.