java程序中取得spring管理的bean的方法怎么解决

如题所述

Spring 文件中将bean注入到想要获得该bean的类中。

或者:
ApplicationContext app=WebApplicationContextUtils.getWebApplicationContext(event
.getServletContext());

其中event 是ServletContextEvent 可以在listener中找到
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-10-18
依赖于注入 @Autowired