title: Someone can explain to me for a use case of springboot injection
body: <p>I read these lines from a colleague's code: </p>
  
  <pre class="lang-java prettyprint-override"><code>    @Bean(name = "mysql")
      @ConfigurationProperties(prefix = "spring.mysql")
      @Primary
      public DataSource mysqlDataSource() {
          return DataSourceBuilder.create().build();
      }
  
      @Bean
      public ClassA classA () {
          return new ClassA (this.mysqlDataSource());
      }
  
      @Bean
      public ClassB classB () {
          return new ClassB (this.mysqlDataSource());
      }
  </code></pre>
  
  <p>I thought this will create 2 DataSources for Bean classA and classB. for injecting the datasource, we need something like:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Bean
      public ClassA classA (DataSource ds) {
          return new ClassA (ds);
      }
  </code></pre>
  
  <p>But Spring just create one datasource, and this.mysqlDataSource() returns the same one everytime. how does it happen? If I do need another DataSource, i need create it on the fly?</p>