Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. liquibase.user=abc
  2. liquibase.password=xyz
  3. liquibase.url=jdbc:postgresql://something.eu-west-1.rds.amazonaws.com:5432/app?ApplicationName=${appName}-liquibase
  4. liquibase.enabled=true
  5. liquibase.contexts=dev,postgres
  6.  
  7. @Configuration
  8. public class LiquibaseDataSourceConfiguration {
  9.  
  10. private static final Logger LOG = LoggerFactory.getLogger(LiquibaseDataSourceConfiguration.class);
  11.  
  12. @Autowired
  13. private LiquibaseDataSourceProperties liquibaseDataSourceProperties;
  14.  
  15. @LiquibaseDataSource
  16. @Bean
  17. public DataSource liquibaseDataSource() {
  18. DataSource ds = DataSourceBuilder.create()
  19. .username(liquibaseDataSourceProperties.getUser())
  20. .password(liquibaseDataSourceProperties.getPassword())
  21. .url(liquibaseDataSourceProperties.getUrl())
  22. .driverClassName(liquibaseDataSourceProperties.getDriver())
  23. .build();
  24. if (ds instanceof org.apache.tomcat.jdbc.pool.DataSource) {
  25. ((org.apache.tomcat.jdbc.pool.DataSource) ds).setInitialSize(1);
  26. ((org.apache.tomcat.jdbc.pool.DataSource) ds).setMaxActive(2);
  27. ((org.apache.tomcat.jdbc.pool.DataSource) ds).setMaxAge(1000);
  28. ((org.apache.tomcat.jdbc.pool.DataSource) ds).setMinIdle(0);
  29. ((org.apache.tomcat.jdbc.pool.DataSource) ds).setMinEvictableIdleTimeMillis(60000);
  30. } else {
  31. // warnings or exceptions, whatever you prefer
  32. }
  33.  
  34. LOG.info("Initialized a datasource for {}", liquibaseDataSourceProperties.getUrl());
  35. return ds;
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement