How to inject ApplicationContext itself

mibutec picture mibutec · Feb 6, 2011 · Viewed 85.9k times · Source

I want to inject an ApplicationContext itself to a bean.

Something like

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

Is that possible in spring?

Answer

sinuhepop picture sinuhepop · Feb 7, 2011

Previous comments are ok, but I usually prefer:

@Autowired private ApplicationContext applicationContext;