Guest User

Untitled

a guest
May 18th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. my.db.user=postgres
  2. my.db.password=root
  3. my.db.url=jdbc:postgresql://localhost:5432/mydb
  4.  
  5. import com.zaxxer.hikari.HikariDataSource;
  6. import org.springframework.boot.context.properties.ConfigurationProperties;
  7. import org.springframework.boot.jdbc.DataSourceBuilder;
  8. import org.springframework.context.annotation.Bean;
  9. import org.springframework.context.annotation.Configuration;
  10. import org.springframework.context.annotation.Primary;
  11.  
  12. @Configuration
  13. public class DatabaseConfig {
  14.  
  15. @Bean
  16. @Primary
  17. @ConfigurationProperties("spring.datasource")
  18. public HikariDataSource dataSource() {
  19. return DataSourceBuilder.create()
  20. .type(HikariDataSource.class)
  21. .build();
  22. }
  23. }
Add Comment
Please, Sign In to add comment