Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. @Configuration
  2.  
  3. public class AppConfig {
  4.  
  5. @Bean(initMethod = "migrate")
  6. Flyway flyway() {
  7. Flyway flyway = new Flyway();
  8. flyway.setBaselineOnMigrate(true);
  9. flyway.setLocations("filesystem:/path/to/migrations/");
  10. flyway.setDataSource(dataSource());
  11. return flyway;
  12. }
  13.  
  14. @Bean @DependsOn("flyway")
  15. EntityManagerFactory entityManagerFactory() {
  16. LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
  17. bean.setDataSource(dataSource());
  18. // other configurations
  19. return bean.getObject();
  20. }
  21.  
  22. @Bean
  23. DataSource dataSource() {
  24. DataSource dataSource = new BasicDataSource();
  25. // data source configuration
  26. return dataSource;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement