数据库迁移不正确

brjng4g3  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(451)

我尝试在spring persistence config中将liquibase设置为javabean,设置hibernate.hbm2ddl.auto=validate,但最终还是失败了
org.springframework.beans.factory.beancreationexception:创建ru.rambler.alexeimohov.spring.persistenceconfig中定义的名为“entitymanagerfactory”的bean时出错:调用init方法失败;嵌套异常为javax.persistence.persistenceexception:[persistenceunit:default]无法构建hibernate sessionfactory;嵌套异常为org.hibernate.tool.schema.spi.schemamanagementexception:架构验证:缺少表[地址]
如果我设置hbm2ddl.auto=update,hibernate构建所有表,liquibase构建databasechangelog和databasechangeloglock。我尝试在liquibase bean上使用@order(ordered.highest\u priority),但没有成功。
在db.init\u 1.0.xml中只有一个表用于测试:

  1. <databaseChangeLog
  2. xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  3. xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
  6. http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
  7. http://www.liquibase.org/xml/ns/dbchangelog
  8. http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
  9. <changeSet author="author" id="1">
  10. <createTable tableName="address"
  11. schemaName="first">
  12. <column name="id" type="bigint">
  13. </column>
  14. </createTable>
  15. </changeSet>
  16. </databaseChangeLog>
i2byvkas

i2byvkas1#

@dependson解决了我的问题。

相关问题