Java 无法将字符串类型的值转换为MethodSecurityMetadataSource(Spring 3.1)
从Spring3.0.0升级到3.1.0后 我无法实例化MethodSecurityInterceptor bean。 以下是Spring 3.0.0中的原始bean定义:Java 无法将字符串类型的值转换为MethodSecurityMetadataSource(Spring 3.1),java,spring,spring-security,Java,Spring,Spring Security,从Spring3.0.0升级到3.1.0后 我无法实例化MethodSecurityInterceptor bean。 以下是Spring 3.0.0中的原始bean定义: <bean id="methodSecurityInterceptor" class="org.springframework.security.access.interce pt.aopalliance.MethodSecurityInterceptor"> <property name="authe
<bean id="methodSecurityInterceptor" class="org.springframework.security.access.interce pt.aopalliance.MethodSecurityInterceptor">
<property name="authenticationManager" ref="myAuthenticationManager" />
<property name="accessDecisionManager" ref="myAccessDecisionManager" />
<property name="securityMetadataSource">
<value>
com.myPackage.foo=ROLE_ADMIN
com.myPackage.bar=ROLE_ADMIN
com.myPackage.inner.*=ROLE_ADMIN
</value>
</bean>
任何帮助都将不胜感激 负责将出现在
securityMetadataSource
值中的字符串转换为MethodSecurityMetadataSource实例的类在Spring 3.1中被删除,这就是为什么会出现异常
虽然在3.1中添加了一个新类:。它在XML文件中为您提供了一个新标记。
因此,不是:
<value>
com.myPackage.foo=ROLE_ADMIN
com.myPackage.bar=ROLE_ADMIN
com.myPackage.inner.*=ROLE_ADMIN
</value>
<value>
com.myPackage.foo=ROLE_ADMIN
com.myPackage.bar=ROLE_ADMIN
com.myPackage.inner.*=ROLE_ADMIN
</value>
<s:method-security-metadata-source>
<s:protect method="com.myPackage.foo" access="ROLE_ADMIN"/>
<s:protect method="com.myPackage.bar" access="ROLE_ADMIN"/>
<s:protect method="com.myPackage.inner.*" access="ROLE_ADMIN"/>
</s:method-security-metadata-source>
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">