title: Specify order to Spring @Autowired
body: <p>I am using Spring Framework 4.</p>
  
  <p>I have a class (say ClassA) in which another class (say ClassB) is been used. ClassA's member variables are getting value from ClassB. ClassB has a static method which read data from properties file. In ClassB a static member variable <code>ApplicationContext</code> is been injected using <code>@Autowired</code> annotation.</p>
  
  <p>What I want is, I want to make sure that when ClassA uses's its member variable it should get all set with values read from properties file. And for that ClassB should get <code>ApplicationContext</code> all set to read from <code>MessageSource</code>.</p>
  
  <p>As ClassA is marked as <code>@Component</code>, Spring loads ClassA, but when it tries to initialize member variables, it is getting <code>NullPointerException</code>, as <code>ApplicationContext</code> is not yet initialized.</p>
  
  <p>So my question here is, Is there any way available to let Spring tell that some bean should be initialized at some order or something like that. I tried using <code>@DependsOn</code> annotation and specified <code>@Bean</code> to the getter method of <code>ApplicationContext</code>. But it gives below exception:</p>
  
  <p><code>Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'applicationContext': Requested bean is currently in creation: Is there an unresolvable circular reference?</code></p>
  
  <p>Any idea on this issue?</p>
  
  <p>Thanks</p>