【问题标题】:Xml Spring config: Unable to locate springframework.org/schema/securityXml Spring 配置:无法找到 springframework.org/schema/security
【发布时间】:2018-11-20 03:30:51
【问题描述】:

我有一个 xml 配置,当我尝试导入 spring-security 命名空间时,它给了我 2 个选择:springframework.org/schema/pspringframework.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'
}

【问题讨论】:

    标签: spring spring-boot gradle spring-security xml-configuration


    【解决方案1】:

    您缺少 xml 文件顶部的 spring 安全命名空间链接,并且您在底部的架构链接中有一个额外的引号。尝试将以下内容添加到 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>
    

    【讨论】:

    • 非常感谢您,先生,我不敢相信我错过了这样的事情
    • 没问题 Lexy,很高兴我能帮上忙。
    猜你喜欢
    • 2011-01-10
    • 1970-01-01
    • 2017-03-03
    • 2014-02-25
    • 2010-12-03
    • 2022-07-04
    相关资源
    最近更新 更多