Java 未找到Spring安全记忆的Spring Bean?
在使用Spring Security的Grails应用程序中,我想在conf/Spring/resource.groovy中初始化以下Springbean:Java 未找到Spring安全记忆的Spring Bean?,java,spring,grails,spring-security,grails-2.0,Java,Spring,Grails,Spring Security,Grails 2.0,在使用Spring Security的Grails应用程序中,我想在conf/Spring/resource.groovy中初始化以下Springbean: beans = { if (grailsApplication.config.grails.plugins.springsecurity.rememberMe.persistent) { rememberMeServices(MyPersistentTokenBasedRememberMeService) {
beans = {
if (grailsApplication.config.grails.plugins.springsecurity.rememberMe.persistent) {
rememberMeServices(MyPersistentTokenBasedRememberMeService) {
userDetailsService = ref('userDetailsService')
key = grailsApplication.config.grails.plugins.springsecurity.rememberMe.key
cookieName = grailsApplication.config.grails.plugins.springsecurity.rememberMe.cookieName
alwaysRemember = grailsApplication.config.grails.plugins.springsecurity.rememberMe.alwaysRemember
tokenValiditySeconds = grailsApplication.config.grails.plugins.springsecurity.rememberMe.tokenValiditySeconds
parameter = grailsApplication.config.grails.plugins.springsecurity.rememberMe.parameter
useSecureCookie = grailsApplication.config.grails.plugins.springsecurity.rememberMe.useSecureCookie // false
tokenRepository = ref('tokenRepository')
seriesLength = grailsApplication.config.grails.plugins.springsecurity.rememberMe.persistentToken.seriesLength // 16
tokenLength = grailsApplication.config.grails.plugins.springsecurity.rememberMe.persistentToken.tokenLength // 16
}
}
}
我在页面底部找到了这个代码
我得到以下错误:
ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'authenticationProcessingFilter': Cannot resolve reference to bean 'rememberMeServices' while setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rememberMeServices': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'int' for property 'tokenLength'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [groovy.util.ConfigObject] to required type [int] for property 'tokenLength': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value of type [groovy.util.ConfigObject]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter': Cannot resolve reference to bean 'rememberMeServices' while setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rememberMeServices': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'int' for property 'tokenLength'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [groovy.util.ConfigObject] to required type [int] for property 'tokenLength': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value of type [groovy.util.ConfigObject]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
为了正确初始化bean,我必须更改什么?
无法将[groovy.util.ConfigObject]类型的值转换为属性“tokenLength”所需的[int]类型
这向我建议,您在grailsApplication.config
中没有设置grails.plugins.springsecurity.rememberMe.persistentoken.tokenLength
属性-当您向ConfigObject
请求不存在的密钥时,它返回给您的是一个新的空ConfigObject