首页>代码>ssm(Spring + Mybatis + SpringMVC) +redis开发网站用户权限后台管理系统>/permission/src/main/Java/com/mall/common/ApplicationContextHelper.java
package com.mall.common;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component("applicationContextHelper")
public class ApplicationContextHelper implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext context) throws BeansException {
        applicationContext = context;
    }

    public static <T> T popBean(Class<T> clazz) {
        if (applicationContext == null) {
            return null;
        }
        return applicationContext.getBean(clazz);
    }

    public static <T> T popBean(String name, Class<T> clazz) {
        if (applicationContext == null) {
            return null;
        }
        return applicationContext.getBean(name, clazz);
    }
}
最近下载更多
sunlea  LV20 8月6日
微信网友_7134912998903808  LV15 2024年8月29日
谯桂生  LV2 2024年6月18日
xuweiwowzy  LV5 2024年2月24日
yyh1252  LV8 2023年12月9日
wuying8208  LV15 2023年11月25日
luoyongbing  LV8 2023年3月30日
hbsoft2008  LV16 2022年11月18日
wz520135  LV7 2022年11月5日
qq1466625431  LV6 2022年6月28日
最近浏览更多
monster_001  LV3 3月25日
万重山 2024年12月18日
暂无贡献等级
AprilZk  LV3 2024年12月11日
微信网友_7134912998903808  LV15 2024年8月29日
暂无贡献等级
谯桂生  LV2 2024年6月18日
yyhrhv  LV8 2024年5月23日
Dominick  LV14 2024年4月29日
xuweiwowzy  LV5 2024年1月14日
minjing123  LV8 2024年1月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友