Grails 3 数据库迁移问题

Grails 3 database-migration issue

我正在使用 database-migration:2.0.0.RC1 和 Grails 3.0.7。我在迁移到 运行 时遇到问题。启动时出现以下错误:

Caused by: java.lang.IllegalArgumentException: Script text to compile cannot be null!
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
    at groovy.lang.GroovyClassLoader.validate(GroovyClassLoader.java:315) ~[groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:275) ~[groovy-2.4.4.jar:2.4.4]
    at org.grails.plugins.databasemigration.liquibase.GroovyChangeLogParser.parseToNode(GroovyChangeLogParser.groovy:74)
    at groovy.lan   at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:17)
g.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) ~[groovy-2.4.4.jar:2.4.4]
    at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:215)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:694) ~[groovy-2.4.4.jar:2.4.4]
    at groovy.lang.GroovyShell.parse(GroovyShell.java:706) ~[groovy-2.4.4.jar:2.4.4]
    at liquibase.Liquibase.update(Liquibase.java:192)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:742) ~[groovy-2.4.4.jar:2.4.4]
    at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:353)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:733) ~[groovy-2.4.4.jar:2.4.4]
    at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:317)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426) ~[springloaded-1.2.4.RELEASE.jar:1.2.4.RELEASE]
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169) ~[groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) ~[groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.4.jar:2.4.4]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.grails.plugins.databasemigration.liquibase.GroovyChangeLogParser.parseToNode(GroovyChangeLogParser.groovy:63) ~[database-migration-2.0.0.RC1.jar:na]
    ... 28 common frames omitted

问题似乎是找不到 changelog.groovy 文件。我在 GroovyChangeLogParser 内部调试,但在这一行失败:

inputStream = StreamUtil.singleInputStream(physicalChangeLogLocation, resourceAccessor)

如果我检查 resourceAccessor,它里面没有 grails-app/migrations 文件夹,所以找不到 changelog.groovy 文件。我不确定从这里去哪里。我是否缺少某些配置或其他内容?我的这个插件在 Grails 2.3.7 项目中运行良好。

您似乎缺少自述文件中提到的 gradle 配置:

https://github.com/yamkazu/database-migration

sourceSets {
    main {
        resources {
            srcDir 'grails-app/migrations'
        }
    }
}