我的项目框架是IBATIS+STRUTS+SRPING。最近研究了下ACEGI,决定用他来做权限控制。我看了SPRING IN ACTION这本书,做了如下配置:
<bean id="daoAuthenticationProvider"
class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="jdbcDaoImpl" />
<property name="userCache">
<ref bean="userCache" />
</property>
<property name="passwordEncoder" ref="passwordEncoder" />
</bean>
<bean id="userCache"
class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
<property name="minutesToIdle" value="15"></property>
</bean>
<bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.Md5PasswordEncoder" />
结果运行起来出现了如下错误:
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: No matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:212)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:127)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:775)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:608)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue。
高手解决 不甚感激!
<bean id="daoAuthenticationProvider"
class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="jdbcDaoImpl" />
<property name="userCache">
<ref bean="userCache" />
</property>
<property name="passwordEncoder" ref="passwordEncoder" />
</bean>
<bean id="userCache"
class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
<property name="minutesToIdle" value="15"></property>
</bean>
<bean id="passwordEncoder" class="org.acegisecurity.providers.encoding.Md5PasswordEncoder" />
结果运行起来出现了如下错误:
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [applicationContext-acegi-security.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in class path resource [applicationContext-acegi-security.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache] to required type [org.acegisecurity.providers.dao.UserCache] for property 'userCache'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: No matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:212)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:127)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:775)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:608)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue。
高手解决 不甚感激!
搜一下,看看有没有定义这些bean如果可以选择的话,不要用老的acegi了,这个东西都已经集成进spring里了,叫做spring security,最新的是3.0.xxx RELEASE
配置要省事很多