uniquejava / blog

My notes regarding the vibrating frontend :boom and the plain old java :rofl.
Creative Commons Zero v1.0 Universal
11 stars 5 forks source link

Scope 'session' is not active for the current thread; #277

Open uniquejava opened 4 years ago

uniquejava commented 4 years ago
  1. 把bean改成Thread Scope. https://memorynotfound.com/spring-custom-scope-creating-and-implementing-threadscope/
  2. 在Thread中不使用依赖注入
  3. 把Thread中依赖的service通过参数传给Thread: https://stackoverflow.com/questions/7405232/why-does-autowiring-not-function-in-a-thread

参考:

  1. https://www.kimullaa.com/entry/2016/11/01/234211
  2. https://stackoverflow.com/questions/21286675/scope-session-is-not-active-for-the-current-thread-illegalstateexception-no