Autowiring a static variable using Spring
Yes, This sounds wrong and should never try to do it in a proper design (According to me). With the above disclaimer, Might run into such a case where we need to do this kind of thing, you are at the right blog. There are 2 ways to do it i guess, i have the simple working way jotted here. Lets get started Consider the class @Component public class Foo { private static ObjectA objectA; // Static variable to be used in static method in class @Autowired ObjectA autowiredObjectA; // Orginal bean that is autowired @postConstruct public void init() { Foo.objectA=this.autowiredObjectA; // So this method is responsible for handing out the bean after the class is constructed and autowired by the spring ...