title: When to use autowiring in Spring
body: <p>I am reading the book <a href="https://rads.stackoverflow.com/amzn/click/com/1430241071" rel="noreferrer" rel="nofollow noreferrer">Pro Spring 3</a>. It has a certain paragraph that really confused me. The paragraph is about autowiring in spring. Here is an excerpt:</p>
  
  <blockquote>
    <p>In most cases, the answer to the question of whether you should use
    autowiring is definitely “no!” Autowiring can save you time in small
    applications, but in many cases, it leads to bad  practices and is
    inflexible in large applications.  Using byName seems like a good
    idea, but it  may lead you to give your classes artificial property
    names so that you can take advantage of the autowiring functionality. 
    The whole idea behind Spring is that you can create your classes how
    you like and have Spring work for you, not the other way around ...</p>
    
    <p>... For any nontrivial application, steer clear of autowiring at all
    costs.</p>
  </blockquote>
  
  <p>I have always been using the @Autowired tag in applications I have created. Can someone explain what is wrong with it and what I should use instead?</p>
  
  <p>A mini example on how I handle most things now is:</p>
  
  <pre><code>@Service("snippetService")
  public class SnippetService {
  
      @Autowired
      private TestService testService;
  
      public Snippet getSnippet() {
          return testService.getSnippet();
      }
  }    
  </code></pre>
  
  <p>Is using autowiring like this "wrong" or am I missing something?</p>