有时候,在非spring管理的类中需要使用spring bean,可以使用下面的代吗获取:
(T) ContextLoader.getCurrentWebApplicationContext().getBean("T");
本文介绍了一种在非Spring管理的类中获取SpringBean的方法,通过使用ContextLoader.getCurrentWebApplicationContext().getBean()来实现跨上下文的Bean访问。
有时候,在非spring管理的类中需要使用spring bean,可以使用下面的代吗获取:
(T) ContextLoader.getCurrentWebApplicationContext().getBean("T");
2642

被折叠的 条评论
为什么被折叠?