package com.baizhi.shiro.Utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class ApplicationContextUtils implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
}
// 根据bean的名字获取工厂中指定的对象
public static Object getBean(String beanName){
return context.getBean(beanName);
}
}
允许转载,若有侵权,将进行追究
若侵权他人,请联系我,进行删除,谢谢
来自一个写代码的小哥哥
若有错误,请联系我,进行修改
写代码,挣钱,努力,挣钱,run,run,run