获取spring管理的bean

来源:互联网 发布:java时间戳精确到毫秒 编辑:程序博客网 时间:2024/06/05 11:23
ServletContext servletContext = this.getServletContext();
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);

bean实例名 = (bean所属类) ctx.getBean("【bean的名称】");

例如:


0 0