gpt4 book ai didi

java - 实现 spring security 时出现 xmlBeanDefinitionStoreException

转载 作者:行者123 更新时间:2023-11-29 03:30:46 24 4
gpt4 key购买 nike

我正在尝试在我的应用程序中实现 spring 安全性> 我正在关注此代码项目教程

http://www.codeproject.com/Articles/253901/Getting-Started-Spring-Security

这里我的 spring-secrity.xml 文件看起来像-

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/security"
xmlns:bean="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">

<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
</http>

<authentication-manager>
<authentication-provider>
<user-service>
<user name="testadmin" password="testadminpassword"
authorities="ROLE_USER, ROLE_ADMIN" />
<user name="testuser" password="testuserpassword" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>

</beans>

但是在运行代码时出现异常-

[2013-08-23 15:27:14,607] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from ServletContext resource [/WEB-INF/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 86; cvc-elt.1: Cannot find the declaration of element 'beans'.

任何人都可以通过灯光了解这里的问题是什么以及如何纠正它,我们将不胜感激。

最佳答案

根据您的命名空间声明 <beans>元素必须以“bean:”为前缀

<?xml version="1.0" encoding="UTF-8"?>
<bean:beans ...>
...
</bean:beans ...>

关于java - 实现 spring security 时出现 xmlBeanDefinitionStoreException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18400134/

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