1

我试图将 Spring 安全性集成到我现有的项目中。我使用的工具是:

  1. 春天 2.5.6.SEC03
  2. 弹簧安全核心 3.1.1.RELEASE
  3. 7.

在弹簧配置中,我有这个:

<beans:beans xmlns="http://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.1.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="/messagePost.htm*" access="ROLE_USER"/>
</http>

<authentication-provider>
  <user-service>
    <user name="user1" password="1111" authorities="ROLE_USER"/>
  </user-service>
</authentication-provider>
</beans:beans>

但是这个spring配置有一个错误:

  1. cvc-complex-type.2.4.c:匹配通配符是严格的,但找不到元素“authentication-provider”的声明。
  2. cvc-complex-type.2.4.c:匹配通配符是严格的,但找不到元素“http”的声明。

我可以知道如何解决这个问题吗?

4

1 回答 1

7

进行这些更改

<?xml version="1.0" encoding="UTF-8"?>
<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.1.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="/messagePost.htm*" access="ROLE_USER"/>
  </http>

  <authentication-manager>
    <authentication-provider>
      <user-service>
        <user name="user1" password="1111" authorities="ROLE_USER"/>
      </user-service>
    </authentication-provider>
  </authentication-manager>

</beans:beans>

我做了以下更改

  1. 将您的 xmlns 架构从更改"http://springframework.org/schema/security""http://www.springframework.org/schema/security"(添加 www :D)
  2. 我已将命名空间包含在<authentication-provider>命名<authentication-manager>空间中。
于 2012-08-21T08:45:02.730 回答