【问题标题】:xmlBeanDefinitionStoreException while implementing spring securityxmlBeanDefinitionStoreException,同时实现弹簧安全
【发布时间】:2013-08-26 08:18:11
【问题描述】:

我正在尝试在我的应用程序中实现 Spring Security> 我正在关注这个代码项目教程

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] 错误 [org.springframework.web.context.ContextLoader] 上下文初始化 失败的 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自 ServletContext 资源的 XML 文档中的第 8 行 [/WEB-INF/spring-security.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException;行号:8;列号:86; cvc-elt.1:找不到元素“beans”的声明。

任何人都可以通过灯光请这里有什么问题以及如何纠正它,任何帮助将不胜感激。

【问题讨论】:

    标签: java xml spring spring-mvc spring-security


    【解决方案1】:

    根据您的命名空间声明,&lt;beans&gt; 元素必须以“bean:”为前缀

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

    【讨论】:

      【解决方案2】:

      这里有两个问题: 首先:你必须写:

      <beans:beans ....
      </beans:beans>
      

      秒:

      xmlns:beans="http://www.springframework.org/schema/beans"
      

      而不是

      xmlns:bean="http://www.springframework.org/schema/beans"
      

      【讨论】:

        猜你喜欢
        • 2023-01-03
        • 2018-09-08
        • 1970-01-01
        • 2020-09-19
        • 2017-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多