15年软件开发经验 只做源码定制 互联网+定制化解决方案

15年软件开发经验,只做源码定制!

原创设计 定制开发

满足您的个性化需求

当前位置:首页 后端开发 java

springboot项目中运行spring security 报 Error creating bean with name 'springSecurityFilterChain'错误

庞凯博| 发布于 2021-10-26 22:15:25| 514阅读| 0点赞| 0评论
举报

问题描述: 启动springboot项目,直接编译报错,内容:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource

启动springboot项目,直接编译报错,内容:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException

简单理解:在启动springboot项目时,会自动去加载SecurityConfig这个类 里面的配置(SecurityConfig类是自己写的,用来继承WebSecurityConfigurerAdapter 实现自定义登录),其他底层的不多说,解决方案:在springboot启动类中加入手动注解, 

这样子再次启动springboot就无问题了

原因:是 [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class] 在类路径资源中定义名称为“springSecurityFilterChain”的Bean创建错误,不像springboot 2.xxx版本是自动扫描的,所以这里需要手动添加
建议:使用springboot版本2.xxx 以上,方便快捷

————————————————
原文链接:https://blog.csdn.net/qq_37736010/article/details/104894948


0

0条评论

别默默看啦~登录/注册一起参与讨论吧~

热门标签

庞凯博
微信扫一扫立即咨询
账号登录|扫码登录

立即注册 |忘记密码?

欢迎注册

已有账号马上登录

重置密码

扫码绑定微信
微信扫一扫

绑定手机号

分享到-微信

举报

  • 举报类型:

  • 举报描述:

您好,当前积分不足。

在线客服
拨打电话
17330196230 13230981129
顶部