我有一个xml配置,当我尝试导入spring-security命名空间时,它给了我两个选择:springframework.org/schema/p
和springframework.org/schema/c
。我需要的是:http://www.springframework.org/schema/security(无法找到)。这是一个spring boot项目,我需要使用xml配置安全性。我想我错过了一些依赖,但我不确定是哪一个。
这是xml配置文件:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
build.gradle依赖项:
dependencies {
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.0.6.RELEASE'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.0.5.RELEASE'
}
答案 0 :(得分:1)
您错过了xml文件顶部的spring security命名空间链接,并且您在底部的架构链接中有一个额外的引用。尝试将以下内容完全添加到xml文件中,如下所示:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
</beans>