【问题标题】:Liquibase Groovy-DSL SpringLiquibase Groovy-DSL Spring
【发布时间】:2016-03-09 23:31:23
【问题描述】:

我正在开发一个spring-shell 数据库迁移工具。

目前我尝试将 liquibase 与 groovy-dsl extension 一起使用。 我的 build.gradle 包括扩展 jar,我还在 spring-shell-plugin.xml 中声明了 liquibase

spring-shell-plugin.xml

<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase" depends-on="postgresService">
    <property name="dataSource" ref="psqlDataSource"/>
    <property name="changeLog" value="com.example.db.DbChangelog_master"/>
    <property name="defaultSchema" value="${postgres.schema}"/>
</bean>

但是每次我启动应用程序 liquibase 都会抛出以下错误

Caused by: liquibase.exception.UnknownChangelogFormatException: Cannot find parser that supports com.example.db.DbChangelog_master
    at liquibase.parser.ChangeLogParserFactory.getParser(ChangeLogParserFactory.java:70)
    at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:226)
    at liquibase.Liquibase.update(Liquibase.java:202)
    at liquibase.Liquibase.update(Liquibase.java:192)
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 13 more

文档有点少,jar 也包含在类路径中。

groovy 脚本是否需要在src/main/resources 中?目前它们在src/main/groovy的单独包中

【问题讨论】:

    标签: java spring groovy liquibase spring-shell


    【解决方案1】:

    我认为你的财产

    <property name="changeLog" value="com.example.db.DbChangelog_master"/>
    

    不正确。这应该是您的更改日志文件的路径。如果该文件是 groovy 文件,它可能是

    <property name="changeLog" value="DbChangelog_master.groovy"/>
    

    如果该文件在类路径中可用。

    【讨论】:

    • 你也想过。太专注于其他事情了,我明天会提前尝试一下 :)
    • 不能引用类,需要引用 groovy 脚本的路径
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 2018-05-22
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多