Xml Spring 配置:无法定位 springframework。org/schema/security
Xml Spring config: Unable to locate springframework.org/schema/security
我有一个 xml 配置,当我尝试导入 spring-security 命名空间时,它给了我 2 个选择:springframework.org/schema/p
和 springframework.org/schema/c
。我需要的是:http://www.springframework.org/schema/security(找不到)。这是一个 spring 引导项目,我需要使用 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'
}
您在 xml 文件的顶部缺少 spring 安全命名空间 link,并且您在 links 上的架构中有一个额外的引号底部。尝试将以下内容添加到 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>
我有一个 xml 配置,当我尝试导入 spring-security 命名空间时,它给了我 2 个选择:springframework.org/schema/p
和 springframework.org/schema/c
。我需要的是:http://www.springframework.org/schema/security(找不到)。这是一个 spring 引导项目,我需要使用 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'
}
您在 xml 文件的顶部缺少 spring 安全命名空间 link,并且您在 links 上的架构中有一个额外的引号底部。尝试将以下内容添加到 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>