Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails 3数据库迁移插件初始化错误_Grails_Liquibase_Grails 3.0 - Fatal编程技术网

Grails 3数据库迁移插件初始化错误

Grails 3数据库迁移插件初始化错误,grails,liquibase,grails-3.0,Grails,Liquibase,Grails 3.0,我最近在Grails3.0.11应用程序中添加了数据库迁移插件。问题是,当我尝试运行应用程序时,出现以下错误: ERROR grails.boot.GrailsApp - Application startup failed Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springLiquibase_dataS

我最近在Grails3.0.11应用程序中添加了数据库迁移插件。问题是,当我尝试运行应用程序时,出现以下错误:

ERROR grails.boot.GrailsApp - Application startup failed
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'springLiquibase_dataSource': 
Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: 
java.lang.IllegalArgumentException: Script text to compile cannot be null!
看起来在我的grails app/migrations文件夹中找不到changelog.xml。My build.gradle文件包含:

buildscript {
    dependencies {
        classpath "org.grails.plugins:database-migration:2.0.0.RC1"
    }
}

我还在application.groovy文件中添加了以下行:

grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']
我非常感谢任何关于如何使数据库迁移插件正常工作的建议

编辑:

我使用
$grailsdbmcreatechangelog
命令创建了changelog.xml文件

我还添加了build.gradle(正如
$grails plugin info database migration
命令所建议的那样):

然后我将其更改为(以下为官方文件):

然后(根据启动错误手册的建议),我强制液化:

dependencies {
    compile 'org.liquibase:liquibase-core:3.3.2'
    runtime 'org.grails.plugins:database-migration:2.0.0.RC1'
}

问题仍然存在:
java.lang.IllegalArgumentException:要编译的脚本文本不能为null

确保:

  • 您已经设置了变更日志,即文件
    grails app/migrations/changelog.xml
    存在并且有效
  • 你如何做到这一点取决于你的情况。插件的文档中有一节介绍了如何最初创建文件

  • 您的数据源已设置为使用
    changelog.xml
    适用的数据库

  • 我们在升级到Grails3时遇到了同样的问题

    通过查看
    grails数据库迁移
    插件的代码,可以清楚地看到配置参数已从列表
    updateOnStartFileNames
    更改为单个值
    updateOnStartFileName

    因此,当您从

    grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']
    


    它应该还能工作。

    好的,我终于找到了解决办法。也许有一天它会帮助别人。所以我所做的只是删除changelog.groovy(我从XML切换到groovy)文件。然后,我使用
    $grailsdbmcreatechangelogchangelog.groovy
    命令生成了一个新的。作为最后一步,我运行了
    $grailsdbmchangelogsync
    ,一切都开始正常工作。

    我遇到了类似的错误。在我的例子中,我们有一些查找表,其中我们使用包含在主changelog.groovy中的手工脚本填充,如:

    include file: 'data/001-tablex-data.groovy'
    

    除了文件名不正确-它应该是002-。。。相反错误基本上是相同的,但是没有报告表明未找到/解析包含的文件,这是一个难题。因此,如果您手动包含文件,那么除了检查顶级changelog.groovy或changelog.xml之外,还要查找名称不正确的文件。我们遇到的另一个可能导致此问题的原因是不正确的大小写。如果changelog.groovy引用了
    path/someFile.groovy
    ,但实际名称是
    path/someFile.groovy
    ,则会出现此错误。确保路径名大小写匹配。

    我也遇到了这个问题,在我的情况下,问题是
    build.gradoe中该块的顺序

    sourceSets {
        main {
            resources {
                srcDir 'grails-app/migrations'
            }
        }
    }
    
    它必须在
    引导运行之前,如下面的代码

    sourceSets {
        main {
            resources {
                srcDir 'grails-app/migrations'
            }
        }
    }
    
    bootRun {
        jvmArgs(
                '-Dspring.output.ansi.enabled=always',
                '-noverify',
                '-XX:TieredStopAtLevel=1',
                '-Xmx1024m')
        sourceResources sourceSets.main
        String springProfilesActive = 'spring.profiles.active'
        systemProperty springProfilesActive, System.getProperty(springProfilesActive)
    }
    

    如果将
    sourceset
    放在
    bootRun
    之后,应用程序将找不到迁移文件。

    Hi!谢谢你的回答。这不是一个解决办法。我忘记在问题描述中添加运行时依赖项。我据此编辑了我的问题。这不是真正问题的解决方案。通过确保使用默认的changelog脚本名称,您已经解决了这个问题。我的答案解决了这个问题这是正确的答案,当一个导入文件找不到时,问题就出现了,它可能是其中一个,甚至是更新文件名(changelog.xml或changelog.groovy)
    grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']
    
    grails.plugin.databasemigration.updateOnStartFileName = 'changelog.xml'
    
    include file: 'data/001-tablex-data.groovy'
    
    sourceSets {
        main {
            resources {
                srcDir 'grails-app/migrations'
            }
        }
    }
    
    sourceSets {
        main {
            resources {
                srcDir 'grails-app/migrations'
            }
        }
    }
    
    bootRun {
        jvmArgs(
                '-Dspring.output.ansi.enabled=always',
                '-noverify',
                '-XX:TieredStopAtLevel=1',
                '-Xmx1024m')
        sourceResources sourceSets.main
        String springProfilesActive = 'spring.profiles.active'
        systemProperty springProfilesActive, System.getProperty(springProfilesActive)
    }