获取 Spring 应用上下文
使用工具类
如果你的项目中有一个工具类实现了 ApplicationContextAware 接口,如 cn.shutdown.pf.utils.SpringContextUtils,可以使用该类获取 ApplicationContext:
@Component
public final class SpringContextUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextUtils.applicationCo

最低0.47元/天 解锁文章
1731

被折叠的 条评论
为什么被折叠?



