Smr*_*ita 1 java spring spring-mvc spring-security
我的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>
Run Code Online (Sandbox Code Playgroud)
但是我遇到了以下错误
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.
Run Code Online (Sandbox Code Playgroud)
可能有什么问题?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+'
Run Code Online (Sandbox Code Playgroud)
您的 XML 文档将 Spring beans 命名空间作为默认命名空间。http
Spring Security 中的元素和其他元素位于 security 命名空间中。你需要前缀:
<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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1693 次 |
最近记录: |