Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my.db.user=postgres
- my.db.password=root
- my.db.url=jdbc:postgresql://localhost:5432/mydb
- import com.zaxxer.hikari.HikariDataSource;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.boot.jdbc.DataSourceBuilder;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.context.annotation.Primary;
- @Configuration
- public class DatabaseConfig {
- @Bean
- @Primary
- @ConfigurationProperties("spring.datasource")
- public HikariDataSource dataSource() {
- return DataSourceBuilder.create()
- .type(HikariDataSource.class)
- .build();
- }
- }
Add Comment
Please, Sign In to add comment