在多线程中获取spring bean为null的解决

网上找了不少方法试,只有下面这种方式能在新开的线程中访问到beanspa

   WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
   ZlAreaAliasService zlAreaAliasService=(ZlAreaAliasService) context.getBean("zlAreaAliasService");线程

获取当前的WebAppliactionContext(),再获取context中的bean;get

相关文章
相关标签/搜索