liquibase-maven-plugin 和 hibernate:diff 命令不产生任何变更集

问题描述

我正在尝试将 liquibase 和 hibernate 放在一起,以在开发或更新实体时生成新的变更集。我已经在非 jpa 场景中使用了 liquibase,所以我决定在这个用例中使用它。我想我正确设置了所有内容(检查 here 子模块 jsfcihelloworld)但是当我运行 mvn liquibase:diff -Dliquibase.diffChangeLogFile=/tmp/database.change.log.txt 时没有发现任何变化,这是(相关部分)输出

Starting Liquibase at 15:40:51 (version 4.2.2 #36 built at 2020-12-09 20:07+0000)
[INFO] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringBeanDatabase Could not be instantiated
[INFO] Cannot load service: liquibase.database.Database: Provider liquibase.ext.hibernate.database.HibernateSpringPackageDatabase Could not be instantiated
[INFO] Executing on Database: jdbc:postgresql://localhost:5432/postgres
[WARNING] Namespace of the [javax.xml.bind.annotation.XmlSchema] annotation does not match [http://www.hibernate.org/xsd/orm/hbm]. Processing bindings will probably fail.
[INFO] Reading hibernate configuration hibernate:ejb3:jscihw?dialect=org.hibernate.dialect.Postgresql95Dialect
....
[INFO] Performing Diff on database postgres @ jdbc:postgresql://localhost:5432/postgres (Default Schema: public)
[INFO] Found table kind
[INFO] Found table kind
[INFO] Found table users
[INFO] Found table users
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table move_something
[INFO] Found table generic_good
[INFO] Found table generic_good
[INFO] Found table move_something_complex
[INFO] Found table move_something_complex
[INFO] Found table generic_good
[INFO] Found primary key generic_goodPK
[INFO] Found column id uuid
[INFO] Found column description varchar(255)
[INFO] Found table kind
[INFO] Found primary key kindPK
[INFO] Found column id uuid
[INFO] Found column name varchar(255)
[INFO] Found table users
[INFO] Found primary key usersPK
[INFO] Found column id uuid
[INFO] Found column age int4
[INFO] Found column name varchar(255)
[INFO] Found column since timestamp
[INFO] Found column surname varchar(255)
[INFO] Found table move_something_complex
[INFO] Found unique constraint UK_b1eoi866ojglucgyhvmfssp83 on move_something_complex(component_task)
[INFO] Found column main_task uuid
[INFO] Found column component_task uuid
[INFO] Found column id uuid
[INFO] Found table move_something
[WARNING] Hibernate primary key name is probably truncated. move_somethinPK
[WARNING] Changing hibernate primary key name to move_somethingPK
[INFO] Found primary key move_somethingPK
[INFO] Found column DTYPE varchar(31)
[INFO] Found column id uuid
[INFO] Found column ends_at timestamp
[INFO] Found column starts_at timestamp
BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed.
[INFO] /tmp/database.change.log.txt exists,appending
[INFO] No changes found,nothing to do
[INFO] Differences written to Change Log File,/tmp/database.change.log.txt

看起来像 liquibase find changes,generic_good move_somethingmove_somenthing_complex 是新实体,但 changelog 是空的。我错过了什么?

解决方法

输出对我来说似乎有点误导,因为你是对的,看起来 liquibase 发现了 generic_good move_something 和 move_somenthing_complex 的变化。

我认为问题在于您使用的是 liquibase diff,但我认为您想使用 liquibase diffChangeLog。 diffChangeLog 实际上生成了一个运行

我看到的另一个问题是您正在使用

-Dliquibase.diffChangeLogFile=

在文档中,输出文件为:

  • diff 是 --outputFile=mydiff.txt 和
  • diffChangeLog 是 --changeLogFile=dbchangelog.xml