标签:ApplicationContext

SpringBoot获取ApplicationContext

发表于0年前(Feb 26, 2017 1:20:37 PM)  阅读 709  评论 0

分类: Java

标签: spring ApplicationContext WebApplicationContext ApplicationContextAware

首先来看一个工具类:

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

public class SpringUtil {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}
	
	private static WebApplicationContext ac = null;
	
	private static ApplicationContext getApplicationContext() {
		if(ac==null) {
			ac = ContextLoader.get
......