如何注入ApplicationContext本身 [英] How to inject ApplicationContext itself

查看:206
本文介绍了如何注入ApplicationContext本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个 ApplicationContext 本身注入一个bean。

I want to inject an ApplicationContext itself to a bean.

类似

public void setApplicationContext(ApplicationContect context) {
  this.context = context;
}

春天有可能吗?

推荐答案

之前的评论还可以,但我通常更喜欢:

Previous comments are ok, but I usually prefer:

@Autowired private ApplicationContext applicationContext;

这篇关于如何注入ApplicationContext本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆