簡體   English   中英

帶有Http標簽的Spring安全問題

[英]Spring security issue with Http tag

我的spring配置文件如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security.xsd
    ">

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

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

</beans>

但是我遇到了以下錯誤

cvc-complex-type.2.4.a: Invalid content was found starting with element 'http'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://
 www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.

有什么可能是錯的嗎? Eclipse所示的錯誤十字標記正好位於http標記開始的位置。

更新我正在使用gradle並且我的build.gradle文件具有以下Spring依賴項:

 compile 'org.slf4j:slf4j-api:1.7.12'
    compile 'com.googlecode.json-simple:json-simple:1.1.1'
    compile 'de.grundid.opendatalab:geojson-jackson:1.0'
    compile 'org.springframework:spring-web:4.2.5.RELEASE'
    compile 'org.springframework:spring-webmvc:4.2.5.RELEASE'
    compile 'org.springframework:spring-jdbc:4.2.5.RELEASE'
    compile 'org.springframework:spring-core:4.2.5.RELEASE'
    compile 'org.springframework:spring-context:4.2.5.RELEASE'
    compile 'org.springframework:spring-aop:4.2.5.RELEASE'
    compile 'org.springframework.security:spring-security-web:4+'
    compile 'org.springframework.security:spring-security-config:4+'

以下Spring依賴項在我的項目的構建路徑中: 在此處輸入圖片說明

您的XML文檔將Spring bean名稱空間作為默認名稱空間。 Spring Security中的http元素和其他元素位於安全名稱空間中。 您需要添加前綴:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM