添加spring security lib时出错

时间:2013-06-06 14:14:12

标签: spring spring-security

我找到了一些解决方案,但它们对我没用。我在项目中添加了库,但是我收到了这个错误。我可以从我的控制器类到达安全库。有什么想法吗?

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration     problem: Unable to locate Spring NamespaceHandler for XML schema namespace     [http://www.springframework.org/schema/security] 
Offending resource: ServletContext resource [/WEB-INF/spring-security.xml]

这是我的spring-security.xml

<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="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.1.xsd">

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

<authentication-manager>
  <authentication-provider>
    <user-service>
    <user name="test" password="123" authorities="ROLE_USER" />
    </user-service>
  </authentication-provider>
</authentication-manager>

</beans:beans>

2 个答案:

答案 0 :(得分:0)

使用http://www.springframework.org/schema/security/spring-security-3.0.xsd作为命名空间。

答案 1 :(得分:0)

避免

"org.xml.sax.SAXParseException: schema_reference.4: Failed to read
 schema document 'springframework.org/schema/security/…;, because 1)
 could not find the document; 2) the document could not be read; 3) the
 root element of the document is not <xsd:schema>."

springframework.org/schema/security/spring-security-3.1.4.xsd更改为springframework.org/schema/security/spring-security-3.1.xsd