Flyway Migration with java

前端 未结 3 1049
挽巷
挽巷 2021-01-15 14:32

I learnt flywaydb migration with java works with JDBC connection and also spring support through SpringTemplate, but flyway doesn\'t work with DAOs.

for tables/entit

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 14:43

    First, Flyway has its own transaction managing system and does not use Spring transaction handling.

    If your DAOs extend JdbcDaoSupport, you could instantiate manually the your DAO and then manually inject the provided JdbcTemplate in the DAO:

    public class MyJdbcMigration implements SpringJdbcMigration {
      public void migrate(JdbcTemplate jdbcTemplate) {
        MyJdbcDao dao = new MyJdbcDao();
        dao.setJdbcTemplate(jdbcTemplate);
        dao.updateDate();
      }
    }
    

提交回复
热议问题