gpt4 book ai didi

java - spring-security-samples-preauth-xml 示例无法运行

转载 作者:行者123 更新时间:2023-11-30 08:52:43 25 4
gpt4 key购买 nike

项目: https://github.com/spring-projects/spring-security/tree/master/samples/preauth-xml

尝试运行上面的项目时,出现以下异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#ec8a0ac': Cannot resolve reference to bean 'fsi' while setting constructor argument with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fsi' defined in ServletContext resource [/WEB-INF/applicationContext-security.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ROLE_USER, ROLE_SUPERVISOR, ROLE_USER]

与错误相关的 XML 代码:

<bean id="fsi" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="httpRequestAccessDecisionManager"/>
<property name="securityMetadataSource">
<sec:filter-security-metadata-source>
<sec:intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/>
<sec:intercept-url pattern="/secure/**" access="ROLE_USER"/>
<sec:intercept-url pattern="/**" access="ROLE_USER"/>
</sec:filter-security-metadata-source>
</property>
</bean>

试过在tomcat 6和7上运行,出现同样的错误。任何提示或帮助将不胜感激。谢谢。

最佳答案

示例未正确迁移到 Spring Security 4。我记录了一个错误 (SEC-2966) 和 fixed it .问题是 Spring Security 4 中的 use-expression 属性被默认更改为 true。所以我们需要明确声明它为 false:

<sec:filter-security-metadata-source use-expressions="false">
<sec:intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/>
<sec:intercept-url pattern="/secure/**" access="ROLE_USER"/>
<sec:intercept-url pattern="/**" access="ROLE_USER"/>
</sec:filter-security-metadata-source>

关于java - spring-security-samples-preauth-xml 示例无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30099851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com