我在我的应用程序中使用了请求范围的bean:
@Bean
@RequestScope
public BeanA beanA(){
return new BeanA();
}
而且,只要我收到网络请求,就可以了。 问题是我现在也支持其他请求源(例如Spring数据redis监听器),但是当我想用值填充它时,我会得到
no thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
是否可以创建请求范围?