wuxw7
2018-04-14 f3bf189c4ffd4fa43f5384dce87b8120a80ed428
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.java110.common.factory;
 
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
 
/**
 * Created by wuxw on 2017/4/25.
 */
 
public class ApplicationContextFactory {
 
    private static ApplicationContext applicationContext;
 
    public static void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
        ApplicationContextFactory.applicationContext = applicationContext;
    }
 
    public static Object getBean(Class className){
        return applicationContext.getBean(className);
    }
 
    public static Object getBean(String beanName){
        return applicationContext.getBean(beanName);
    }
}