All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.magicpotato.fast.quartz.utils.SpringContextUtil Maven / Gradle / Ivy

The newest version!
package top.magicpotato.fast.quartz.utils;

import org.springframework.context.ApplicationContext;

/**
 * @author ycl
 */
public class SpringContextUtil {

    private static ApplicationContext applicationContext;

    public static void setApplicationContext(ApplicationContext applicationContext) {
        SpringContextUtil.applicationContext = applicationContext;
    }

    /**
     * 根据名字获取 bean
     * @param beanName
     * @param 
     * @return
     */
    @SuppressWarnings("unchecked")
    public static  T getBean(String beanName) {
        return (T) applicationContext.getBean(beanName);
    }

    /**
     * 根据类型搜索 bean
     * @param clazz
     * @param 
     * @return
     */
    public static  T getBean(Class clazz) {
        return (T) applicationContext.getBean(clazz);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy