使用不同代理运行 liquibase 时出现问题
我需要先由 ant 执行相同的 db-changelog,然后由 spring 执行。我希望ant能够运行changelog,并且当spring运行时,它不会做任何事情,只是正常停止。 Ant成功运行db-changelog,然后spring运行,但它抛出异常,堆栈跟踪的一部分:
原因:liquibase.exception.JDBCException:执行SQL CREATE TABLE操作时出错(action_id int8 NOT NULL,action_name VARCHAR(255),version_no int8,reason_required BOOLEAN,comment_required BOOLEAN,step_id int8,约束action_pkey主键(action_id)): 原因:执行 SQL CREATE TABLE 操作时出错(action_id int8 NOT NULL、action_name VARCHAR(255)、version_no int8、reason_required BOOLEAN、comment_required BOOLEAN、step_id int8、CONSTRAINT action_pkey PRIMARY KEY (action_id)): 原因:错误:关系“action”已经存在;嵌套异常是 org.springframework.beans.factory.BeanCreationException...
任何帮助将不胜感激。
问候,
I need to execute the same db-changelog by ant and then by spring. I hope that ant will run the changelog and when spring run, it will not do anything and just stop normally. Ant run the db-changelog successfully and then spring run but it throws an exception, part of the stack trace :
Reason: liquibase.exception.JDBCException: Error executing SQL CREATE TABLE action (action_id int8 NOT NULL, action_name VARCHAR(255), version_no int8, reason_required BOOLEAN, comment_required BOOLEAN, step_id int8, CONSTRAINT action_pkey PRIMARY KEY (action_id)):
Caused By: Error executing SQL CREATE TABLE action (action_id int8 NOT NULL, action_name VARCHAR(255), version_no int8, reason_required BOOLEAN, comment_required BOOLEAN, step_id int8, CONSTRAINT action_pkey PRIMARY KEY (action_id)):
Caused By: ERROR: relation "action" already exists; nested exception is org.springframework.beans.factory.BeanCreationException....
Any help will much appreciated.
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来确实像是在尝试再次运行变更日志。变更日志中的每个变更集均由 id、作者和变更日志路径/文件名的组合来标识。如果运行“select * from databasechangelog”,您可以看到使用的值。
您的问题可能是您引用的变更日志文件与 ant 和 spring 不同,因此生成了不同的文件名值。通常您会希望将它们包含在类路径中,因此无论您在何处以及如何运行它们,它们都具有相同的路径(例如“com/example/db.changelog.xml”)
It does sound like it is trying to run the changelog again. Each changeSet in the changeLog is identified by a combination of the id, author, and the changelog path/filename. If you run "select * from databasechangelog" you can see the values used.
Your problem may be that you are referencing the changelog file differently from ant and spring therefore generating different filename values. Usually you will want to include them in the classpath so no matter where and how you run them they have the same path (like "com/example/db.changelog.xml")
我遇到了同样的问题,并且能够通过更改 DATABASECHANGELOG 的文件名列以引用 spring 资源路径来修复它。就我而言,我使用的是 WEB-INF 目录下的 ServletContextResource:
I ran into this same problem and was able to fix it by altering the filename column of DATABASECHANGELOG to reference the spring resource path. In my case, I was using a ServletContextResource under the WEB-INF directory: