【发布时间】:2020-08-27 01:25:50
【问题描述】:
我使用 Jhipster 6.10 创建了一个项目。然后,我生成了实体并检查了一切是否正常。我使用 jhipster entity EntityName 命令在其中一个实体中添加了一个新字段。当我重新加载项目时,Liquibase 给了我一个错误:
liquibase.exception.ValidationFailedException: Validation Failed:
2 change sets check sum
config/liquibase/changelog/20200718175552_added_entity_ChatRoom.xml::20200718175552-1::jhipster was: 8:38306369febaf4b6a6b6ba7a88f73330 but is now: 8:412ef0706ed57049a9803f912e238bbb
config/liquibase/changelog/20200718175552_added_entity_ChatRoom.xml::20200718175552-1-data::jhipster was: 8:57a6e15b897abad245853f04c91b731e but is now: 8:5c0cf1cea40b2c47cddc2c1173a81567
所以我用 gradlew clean 清理了 H2 开发数据库,重新启动项目,一切正常。
我的问题是我应该如何进行生产。这个问题:
Jhipster entity sub generator: How to create liquibase DELTA changelogs?
为 maven 提供 anwser,但我使用的是 gradle。
PS:我在 Postgres 的一个新开发项目上按照 Gael 回答并运行:
D:\JHipster\liquipostgres>gradlew 编译 liquiposrgres:diff
FAILURE:构建失败并出现异常。
出了什么问题:根项目 'liquipostgres' 中的任务 'compile' 不明确。候选对象是:'compileJava'、'compileTestJava'。
尝试:运行 gradlew 任务以获取可用任务的列表。使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
通过https://help.gradle.org获得更多帮助
1 秒内构建失败
FAILURE:构建失败并出现异常。
评估设置ITIALIZING [18ms]
出了什么问题:根项目 'liquipostgres' 中的任务 'compile' 不明确。候选对象是:'compileJava'、'compileTestJava'。
尝试:运行 gradlew 任务以获取可用任务的列表。使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
在https://help.gradle.org 获得更多帮助 1 秒内构建失败
当我执行以下操作时: gradlew liquibaseDiffChangelog -PrunList=diffLog 即使 liquibase 已连接并使用 postgres 数据源创建表,我也会收到此错误:
19:22:47.959 调试 [liquibase.servicelocator.ServiceLocator]: liquibase.ext.hibernate.database.HibernateSpringBeanDatabase 匹配 liquibase.database.Database 19:22:47.987 调试 [liquibase.database.DatabaseFactory]:属性:19:22:47.987 调试 [liquibase.database.DatabaseFactory]:密钥:'密码' 值:'**********' 19:22:47.987 调试 [liquibase.database.DatabaseFactory]:键:'user' 值:'liquipostgres' 19:22:47.987调试[liquibase.database.DatabaseFactory]:连接到 URL:'jdbc:postgresql://localhost:5432/liquipostgres' 使用 驱动程序:'org.postgresql.Driver' 19:22:48.102 错误 [liquibase.integration.commandline.Main]:运行出现意外错误 Liquibase:org.postgresql.util.PSQLException:致命:la autentificaci¾n 密码 fall¾ para el usuario ½liquipostgres╗ (pgjdbc:自动检测到的服务器编码为 ISO-8859-1,如果消息 不可读,请检查数据库日志和/或主机、端口、数据库名称、 用户、密码、pg_hba.conf)liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException:致命:la autentificaci¾n 密码 fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected 服务器编码为 ISO-8859-1,如果消息不可读, 请检查数据库日志和/或主机、端口、数据库名称、用户、密码、 pg_hba.conf) 在 liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:132) 在 liquibase.integration.commandline.Main.doMigration(Main.java:1339) 在 liquibase.integration.commandline.Main.run(Main.java:302) 在 liquibase.integration.commandline.Main.main(Main.java:159) 引起:liquibase.exception.DatabaseException: org.postgresql.util.PSQLException:致命:la autentificaci¾n 密码 fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected 服务器编码为 ISO-8859-1,如果消息不可读, 请检查数据库日志和/或主机、端口、数据库名称、用户、密码、 pg_hba.conf) 在 liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:263) 在 liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149) 在 liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:97) ...省略了 3 个常见框架 原因:org.postgresql.util.PSQLException: FATAL: la autentificaci¾n 密码 fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected 服务器编码为 ISO-8859-1,如果消息不可读, 请检查数据库日志和/或主机、端口、数据库名称、用户、密码、 pg_hba.conf) 在 org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525) 在 org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146) 在 org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197) 在 org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) 在 org.postgresql.jdbc.PgConnection.(PgConnection.java:211) 在 org.postgresql.Driver.makeConnection(Driver.java:459) 在 org.postgresql.Driver.connect(Driver.java:261) 在 liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:255) ...省略了5个常见的框架
FAILURE:构建失败并出现异常。
- 出了什么问题:任务“:liquibaseDiffChangeLog”执行失败。
Process 'command 'C:\Program Files\Java\jdk-11.0.5\bin\java.exe'' 以非零退出值 -1 结束
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
通过https://help.gradle.org获得更多帮助
在 2 秒内构建失败 1 个可操作的任务:1 个已执行
感谢您的帮助。
【问题讨论】:
-
你可以直接使用 liquibase CLI,使用 maven 或 gradle 没有什么价值。见docs.liquibase.com/tools-integrations/cli/…
-
虽然我也会说使用 cli,但您可以通过 ./gradlew liquibaseDiffChangelog -PrunList=diffLog 使用 gradle(就像 maven)来实现。请参阅我们的文档以供参考jhipster.tech/development/…
-
@Gaël Marziou 我已经尝试过您的解决方案,但它对我不起作用。我在问题中添加了错误。谢谢
-
从我读到的,你还没有尝试过我告诉你的,你使用了 gradle 而我的建议是直接使用
liquibase命令。 -
对不起@Gaël Marziou 我在脑海中混合了答案。也感谢您的帮助。没有 ./liquibase.properties 可以按照您的指示进行操作。我无法按照此处的 liquibase 说明进行操作:docs.liquibase.com/commands/community/generatechangelog.html Gael,atomfede 的说明是否有效?这是官方的 jhipster 网站。谢谢