com.github.houbbbbb.sso.nt.util.BeanUtil Maven / Gradle / Ivy
The newest version!
package com.github.houbbbbb.sso.nt.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* @author: hbw
* @date: 2020/7/14
**/
public class BeanUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext ac) throws BeansException {
applicationContext = ac;
}
public static T getBean (Class clazz) {
return applicationContext.getBean(clazz);
}
}