title: Spring Dependency Injection Autowiring Null
body: <p>I was able to use RestTemplate and autowire it. However I want to move my rest template related part of code into another class as follows:</p>
  
  <pre><code>public class Bridge {
  
      private final String BASE_URL = "http://localhost:8080/u";
  
      @Autowired
      RestTemplate restTemplate;
  
      public void addW() {
         Map&lt;String, String&gt; x = new HashMap&lt;String, String&gt;();
         W c = restTemplate.getForObject(BASE_URL + "/device/yeni", W.class, x);
         System.out.println("Here!");
      }
  }
  </code></pre>
  
  <p>And at another class I call it:</p>
  
  <pre><code>...
  Bridge wb = new Bridge();
  wb.addW();
  ...
  </code></pre>
  
  <p>I am new to Spring and Dependency Injection terms. My <code>restTemplate</code>  variable is null and throws an exception. What can I do it how to solve it(I don't know is it related to I use  <code>new</code> keyword)?</p>