博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Security异常之You must provide a configuration attribute
阅读量:7056 次
发布时间:2019-06-28

本文共 986 字,大约阅读时间需要 3 分钟。

    案情描述: 在使用Spring Security框架进行开发的时候,跑出了 “You must provide a configuration attribute”这样的异常,异常详细信息如下:

org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'favSecurityMetadataSource' defined in class path resource [security/spring-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.favccxx.favsecurity.security.FavInvocationSecurityMetadataSourceService]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: You must provide a configuration attribute

    案情分析:从上面的异常信息中可以得到“You must provide a configuration attribute”异常发生在自定义实现“FilterInvocationSecurityMetadataSource”的类中。为什么会发生这样的异常呢?通过接口层层深入,我们可以发现原来异常是在 SecurityMetadataSource 接口抛上来的,SecurityMetadataSource 接口的构造函数中需要一个配置参数。

    在我们自实现FilterInvocationSecurityMetadataSource接口的类中,我们通常也会写类似“loadResourceMatchAuthority”这样加载资源匹配权限的方法,当发生上面的异常时,应该检查如下图所示的代码区域,设置断点,查找发生问题的主要代码。

转载地址:http://ypool.baihongyu.com/

你可能感兴趣的文章
安装Java
查看>>
Ubuntu Linux输入法fcitx方块乱码解决设置
查看>>
node递归批量重命名指定文件夹下的文件
查看>>
python if not用法
查看>>
python-2
查看>>
选择器
查看>>
springMVC参数的获取区别
查看>>
win7电脑数字键盘失灵怎么办
查看>>
java及java web学习笔记
查看>>
SpringMVC+Spring+hibernate整合及分页
查看>>
OpenAI教程
查看>>
LeetCode:459. Repeated Substring Pattern
查看>>
Database Resource website
查看>>
牛客寒假6-E.海啸
查看>>
linq 读取xml
查看>>
const 总结
查看>>
@RestController注解下返回到jsp视图页面
查看>>
搜索框请输入关键字 onfocus 和 onblur
查看>>
随手记:IDAPro蛮强大
查看>>
maven的下载以及安装
查看>>