scope='request'的bean预加载冲突

Error creating bean with name ‘authenticationSuccessServlet’: Scope ‘request’ is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton;
情景:
我自定义了一个spring security中的AuthenticationSuccessHandle类
并在spring security中配置authentication-success-handler-ref
目的是在spring security认证完用户了之后调用自定义的AuthenticationSuccessHandle类中的方法,我想在Session中存放认证用户的id
自定义的AuthenticationSuccessHandle类,我在spring中配置的scope是request

问题描述:
这个scope为request的bean不能被当前线程调用,请将scope改成singleton

原因:
我在网上查到原因是,spring security需要在启动的时候就加载AuthenticationSuccessHandle类,然而spring只在有请求的时候才加载这个类,所以spring security就加载不到

解决方案:
将这个bean的scope改成singleton

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值