当我们修改这个ticket时,我们注意到服务应该实现一个接口,然后,Java类将依赖于这个接口。
如何让SpringSecurityService
实现一个接口,然后在resources.groovy中设置实现
以下不是IoC模式,因为Person.java类依赖于类而不是接口:
import grails.plugin.springsecurity.SpringSecurityService;
class Person {
SpringSecurityService sss;
}
以下是IoC模式:
如果我们有class SpringSecurityService implements IGService{/*...*/}
import grails.facade.IGService
class Person {
IGService sss;
}
然后,在resources.groovy
,我们有:
person(slm.abdennour.Person){
sss=springSecurityService
}
答案 0 :(得分:0)
我找到解决方案,我想分享它:
import grails.plugin.springsecurity.SpringSecurityService;
import grails.facade.IGService;
class CustomerSSS extends SpringSecurityService implements IGService{
}
然后,在resources.groovy
:
springSecurityService(CustomerSSS) {
authenticationTrustResolver = ref('authenticationTrustResolver')
grailsApplication = ref('grailsApplication')
passwordEncoder = ref('passwordEncoder')
objectDefinitionSource = ref('objectDefinitionSource')
userDetailsService = ref('userDetailsService')
userCache = ref('userCache')
}