由于 Gradle 更改:
使用 POM 时分离编译和运行时依赖项
要在 Grails 4 应用程序中使用某些 Grails 3 插件,您需要直接包含它们的传递依赖项。否则它们不会被带入类路径。
解决方法是将依赖项直接包含在您的构建中。
ext {
springSecurityVersion="5.1.6.RELEASE"
springSecurityCoreVersion="4.0.0.RC2"
springSecurityLdapVersion="3.0.2"
}
dependencies {
...
// Security
compile "org.grails.plugins:spring-security-core:$springSecurityCoreVersion"
compile ("org.grails.plugins:spring-security-ldap:$springSecurityLdapVersion") {
exclude group: 'org.grails.plugins', module:'spring-security-core'
}
compile "org.springframework.security:spring-security-ldap:$springSecurityVersion", {
['apacheds-core', 'apacheds-core-entry', 'apacheds-protocol-ldap', 'apacheds-protocol-shared',
'apacheds-server-jndi', 'commons-logging', 'fest-assert', 'jcl-over-slf4j', 'junit',
'ldapsdk', 'logback-classic', 'mockito-core', 'shared-ldap', 'slf4j-api', 'spring-beans',
'spring-context', 'spring-core', 'spring-ldap-core', 'spring-security-core',
'spring-test', 'spring-tx'].each { exclude module: it }
}
compile 'org.springframework.ldap:spring-ldap-core:2.0.4.RELEASE', {
['commons-lang', 'gsbase', 'junit', 'mockito-core', 'powermock-api-mockito',
'powermock-api-support', 'powermock-core', 'powermock-module-junit4',
'powermock-module-junit4-common', 'powermock-reflect', 'slf4j-log4j12', 'spring-beans',
'spring-core', 'spring-data-commons', 'spring-test', 'spring-tx'].each { exclude module: it }
}
我从插件中获取了传递依赖项:
https://github.com/grails-plugins/grails-spring-security-ldap/blob/master/build.gradle#L63-L76