【发布时间】:2020-02-01 08:28:45
【问题描述】:
使用 @Async 注释我想在不同的线程中调用一个方法,该线程可以访问 Session 和 Request 范围的类。
但是,当 ApplicationContext 尝试获取 bean 时,会生成以下异常:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.sessionInfoClass': Scope 'session' is not active for the current thread;
我曾尝试扩展 ApplicationContextAware 类来保存主线程上下文。
我也尝试过这个问题How to enable request scope in async task executor的建议解决方案
源码在 Github
【问题讨论】:
标签: java spring-boot threadpool