title: Spring boot datasource lazy initialization
body: <p><strong>@Lazy</strong> annotation not working on datasource configuration. This datasource autowired into prototype scoped bean, but datasource initialize on startup eager. In stack tracei see call from <strong>TomcatServletWebServerFactory</strong>.</p>
  
  <pre><code>@Configuration
  @Lazy
  public class MsSqlMppvConfig {
  @Bean
  @ConfigurationProperties("spring.mppvdatasource")
  public DataSourceProperties mppvDataSourceProperties() {
      return new DataSourceProperties();
  }
  
  @Bean
  @Lazy
  @Qualifier("mppvdatasource")
  @ConfigurationProperties("spring.mppvdatasource.hikari")
  public DataSource mppvDataSource() {
      return mppvDataSourceProperties().initializeDataSourceBuilder().build();
  }
  
  
  @Bean(name = "tm_mppvdatasource")
  @Autowired
  DataSourceTransactionManager tm(@Qualifier("mppvdatasource") DataSource datasource) {
      return new DataSourceTransactionManager(datasource);
  }}
  
   @Autowired
      @Qualifier("mppvdatasource")
      @Lazy
      DataSource mppvDs;
  </code></pre>
  
  <p>Maybe problem in @Qualifier annotation?</p>