title: Spring annotation @Autowired inside methods
body: <p><code>@Autowired</code> can be used with constructors, setter and class variables. </p>
  
  <p>How can I use the <code>@Autowired</code> annotation inside a method or any other scope.? I tried the following, but it produces compilation errors. For example  </p>
  
  <pre><code>public classs TestSpring {  
    public void method(String param){  
      @Autowired
      MyCustomObjct obj; 
  
      obj.method(param);
    }
  }  
  </code></pre>
  
  <p>If this is impossible, is there any other way to achieve ? (I used Spring 4.)</p>