title: Does Spring @Autowired create new instance of parameters for each bean?
body: <blockquote>
    <p><strong>Does Spring create new instances of constructor parameters of the same type for different beans?</strong></p>
  </blockquote>
  
  <p>For example, I have two REST controllers:</p>
  
  <p><strong>First:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping ("/getHwidData")
  public class GetHwidDataController {
  
      private final ApiKeysDatabase apiKeysDb;
      private final BanwareDatabase banwareDb;
  
      @Autowired
      public GetHwidDataController(ApiKeysDatabase apiKeysDb, BanwareDatabase banwareDb) {
          this.apiKeysDb = apiKeysDb;
          this.banwareDb = banwareDb;
      }
  }
  
  </code></pre>
  
  <p><strong>Second:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping ("/setHwidData")
  public class SetHwidDataController {
  
      private final ApiKeysDatabase apiKeysDb;
      private final BanwareDatabase banwareDb;
  
      @Autowired
      public SetHwidDataController(ApiKeysDatabase apiKeysDb, BanwareDatabase banwareDb) {
          this.apiKeysDb = apiKeysDb;
          this.banwareDb = banwareDb;
      }
  }
  </code></pre>
  
  <p>As you may see, both controllers' constructors are <code>@Autowired</code>, and both accept the same object types: an <code>ApiKeysDatabase</code> and a <code>BanwareDatabase</code>.</p>
  
  <p>I have some caching and other instance-dependent stuff inside those <code>*Database</code> classes, so I'd like to know: when the two above-stated REST controllers are created, <strong>will their <code>apiKeysDb</code> and <code>banwareDb</code> fields be respectively equal</strong> (hold the same instance of the <code>ApiKeysDatabase</code> and <code>BanwareDatabase</code> objects respectively)? That is,</p>
  
  <pre class="lang-java prettyprint-override"><code>GetHwidDataController ctrlOne = ...
  SetHwidDataController ctrlTwo = ...
  
  assertTrue ctrlOne.apiKeysDb == ctrlTwo.apiKeysDb 
          &amp;&amp; ctrlOne.banwareDb == ctrlTwo.banwareDb
  </code></pre>