@Configuration
public class DatabaseConfig {
@Bean
public DataSource dataSource() {
// ...
}
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
// ...
}
}
@Configuration
public class DatabaseConfig {
@Bean
@AutoConfigure("com.mysql.jdbc.Driver")
@DataSourceProperties({
"jdbc.url=jdbc:mysql://localhost/sample",
"jdbc.username=root",
"jdbc.password=123456"
})
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
// ...
}
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>