配置Spring-Security报错,找不到元素 'b:beans&#?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

配置Spring-Security报错,找不到元素 'b:beans&#?报错

2020-06-23 14:53:41 232 1

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)
  • 爱吃鱼的程序员
    2020-06-23 14:54:00

    <?xmlversion="1.0"encoding="UTF-8"?>
    xmlns:security="http://www.springframework.org/schema/security"
    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-3.1.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <security:httpauto-config='true'><curity:http><security:httpauto-config="true"use-expressions="false"access-denied-page="/login.jsp"><security:form-loginlogin-page="/login.jsp"authentication-failure-url="/login.jsp?error=true"authentication-success-handler-ref="loginSuccessHandler"always-use-default-target="true"/><security:logoutlogout-url="/logout"logout-success-url="/login.jsp"/><security:session-management><security:concurrency-controlmax-sessions="1"error-if-maximum-exceeded="false"expired-url="/login.jsp?error=islogin"><curity:concurrency-control><curity:session-management><security:intercept-urlpattern="rvices/**"access="IS_AUTHENTICATED_FULLY"><curity:intercept-url><security:intercept-urlpattern="/jsp/*.jsp"access="IS_AUTHENTICATED_FULLY"><curity:intercept-url><security:custom-filterref="myFilter"before="FILTER_SECURITY_INTERCEPTOR"/><curity:http><security:authentication-manageralias="authenticationManager"><security:authentication-provideruser-service-ref="myUserDetailService"><curity:authentication-provider><curity:authentication-manager><beanid="loginSuccessHandler"class="com.springsecurity.handler.LoginSuccessHandler"><propertyname="jdbcService"ref="jdbcService"/></bean><beanid="myFilter"class="com.springsecurity.filter.MyFilterSecurityInterceptor"><propertyname="authenticationManager"ref="authenticationManager"/><propertyname="accessDecisionManager"ref="myAccessDecisionManagerBean"/><propertyname="securityMetadataSource"ref="mySecurityMetadataSource"/></bean><beanid="myUserDetailService"class="com.springsecurity.handler.MyUserDetailService"><propertyname="userDao"ref="userDao"/><propertyname="jdbcService"ref="jdbcService"/></bean><beanid="myAccessDecisionManagerBean"class="com.springsecurity.filter.MyAccessDecisionManager"><propertyname="myInvocationSecurityMetadataSource"ref="mySecurityMetadataSource"/></bean><beanid="mySecurityMetadataSource"class="com.springsecurity.filter.MyInvocationSecurityMetadataSource"><constructor-arg><refbean="roleDao"/></constructor-arg></bean>

    改成这种即可解决。

    0 0
相关问答

170

回答

惊喜翻倍:免费ECS+免费环境配置~!(ECS免费体验6个月活动3月31日结束)

豆妹 2014-10-29 17:52:21 231981浏览量 回答数 170

8

回答

OceanBase 使用动画(持续更新)

mq4096 2019-02-20 17:16:36 340325浏览量 回答数 8

118

回答

OSS存储服务-客户端工具

newegg11 2012-05-17 15:37:18 300749浏览量 回答数 118

22

回答

爬虫数据管理【问答合集】

我是管理员 2018-08-10 16:37:41 148480浏览量 回答数 22

23

回答

阿里云开放端口权限

xcxx 2016-07-20 15:03:33 657440浏览量 回答数 23

34

回答

Win Server 2003-2016 加密勒索事件必打补丁合集

妙正灰 2017-05-15 10:44:38 283109浏览量 回答数 34

39

回答

安全组详解,新手必看教程

我的中国 2017-11-30 15:23:46 262764浏览量 回答数 39

295

回答

Linux Bash严重漏洞修复紧急通知(已全部给出最终修复方案)

qilu 2014-09-25 13:26:50 437578浏览量 回答数 295

24

回答

【精品问答】python技术1000问(1)

问问小秘 2019-11-15 13:25:00 482949浏览量 回答数 24

13

回答

游戏云精彩帖汇总

nono20011908 2014-08-22 11:00:12 205015浏览量 回答数 13
+关注
爱吃鱼的程序员
https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
2
文章
21568
问答
问答排行榜
最热
最新
相关电子书
更多
OceanBase 入门到实战教程
立即下载
阿里云图数据库GDB,加速开启“图智”未来.ppt
立即下载
实时数仓Hologres技术实战一本通2.0版(下)
立即下载