标签:spring获取applicationc applicationcontext 工具类
(1)实现的工具类:
package com.util; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; final public class ApplicationContextUtil { private static ApplicationContext ac=null; private ApplicationContextUtil(){ } static{ ac=new ClassPathXmlApplicationContext("applicationContext.xml"); } public static ApplicationContext getApplicationContext(){ //获得返回的容器对象 return ac; } }
public static void getByUtil(){ ApplicationContextUtil.getApplicationContext().getBean("userService"); }
Spring获取ApplicationContext对象工具类
标签:spring获取applicationc applicationcontext 工具类
原文地址:http://blog.csdn.net/xlgen157387/article/details/41446077