Liquibase not picking up seed data with Spring Boot

試著忘記壹切 提交于 2019-12-06 01:33:15

I think there are two issues in your changeset 3:

  1. The value of the path property directs to a not existing resource. When you define relativeToChangelogFile="true" then Liquibase will look for classpath:/db/changelog/src/main/resources/.../states.sql. The correct path should be path="../data/states.sql".
  2. If the given path is not correct Liquibase should throw an exception. If you didn't get one means Liquibase decided to not execute that part because of other conditions. One of those conditions could be the dbms property. Your changeset should work with a H2 database. It should not work with a PostgreSQL database because of a wrong type name. Try dbms="h2, postgresql" instead.

After those changes I got a filled table based on your project structure.

This is because by default Hibernate drops the schema when initializing. So first Liquibase creates the data and when finished Hibernate drops the tables and recreates them according to the JPA entities you defined.

You can verify this by looking for the log record:

2017-01-19 11:03:48.692  INFO 15161 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export

You can tell Hibernate not to do anything with the DB schema by setting this application property:

spring.jpa.hibernate.ddl-auto=none
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!