zealot01
zealot01
2016-04-27 08:49

配置Spring-Security报错,找不到元素 'b:beans' 的声明

  • spring

Spring新手,现在想在SpringMVC的基础上使用Spring Security框架。但Spring Security配置报错,困扰了很久。先上代码

 <?xml version="1.0" encoding="UTF-8"?>

<b:beans xmlns="http://www.springframework.org/schema/security" 
        xmlns:b="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemalocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/security 
                            http://www.springframework.org/schema/security/spring-security-3.1.xsd">

报错

 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from class path resource [config/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 99; cvc-elt.1: 找不到元素 'b:beans' 的声明。

尝试网上的方法,加入

 <!DOCTYPE b:beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

则报错

 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from class path resource [config/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 99; 必须声明元素类型 "b:beans"。

请指教

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答