将Grails数据库迁移文件的grails升级到2.5.0时出现Class Not Found错误

Lax*_*khe 3 grails database-migration grails-plugin

我正在尝试将Grails应用程序从2.4.3升级到2.5.0版本.Grails 2.5.0包含修复和改进,但没有任何重大更改.此外,安装了所有2.5.0兼容的插件版本.

还通过Grails Database Migration Plugin changelog和其他插件来支持grails 2.5.0.遇到我现在面临的相同JIRA问题 - Jira Link,但它已经在旧的Grails数据库迁移插件版本中得到修复.

BuildConfig.groovy

grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.reload.enabled = true
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
    inherits("global") {
    }
    log "warn"
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()
        mavenRepo "http://repo.grails.org/grails/core" // Dependency for export plugin.
    }
    dependencies {
        compile ("org.apache.jclouds.provider:cloudfiles-us:1.6.2-incubating", "org.jclouds:jclouds-compute:1.6.0") {
            excludes "jclouds-core"
        }
        compile 'commons-beanutils:commons-beanutils:1.8.3'
        compile "org.apache.jclouds:jclouds-core:1.7.2"
        runtime 'mysql:mysql-connector-java:5.1.29'
    }

    plugins {
        runtime ':database-migration:1.4.0'
        runtime ":hibernate:3.6.10.18"
        runtime ":jquery:1.11.0.2"
        runtime ":resources:1.2.14"
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        build ":tomcat:7.0.55.2"
    }
}
Run Code Online (Sandbox Code Playgroud)

StackTrace 我有一个upgrade-2.1.groovy以默认迁移位置命名的迁移文件grails-app/migrations

| Error 2015-04-30 10:52:09,868 [localhost-startStop-1] ERROR 
    context.GrailsContextLoaderListener  - Error initializing the 
    application: Error creating bean with name 'grailsApplication' 
    defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1
Message: Error creating bean with name 'grailsApplication' defined 
    in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1

    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by GrailsConfigurationException: Class not found loading Grails application: upgrade-2.1
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by ClassNotFoundException: upgrade-2.1
->>  366 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run       in     ''
|    354 | findClass in java.net.URLClassLoader
|    425 | loadClass in java.lang.ClassLoader
|    262 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread
Run Code Online (Sandbox Code Playgroud)

Bur*_*ith 5

这与插件或Grails无关 - 问题是它upgrade-2.1不是Groovy脚本的有效名称.您只能使用有效类名的名称.你必须用另一个角色替换周期,也可能用短划线替换.试试upgrade_2_1.groovy.

  • 文件名中的短划线也在工作,我不必更改它们.防爆.`升级,2_1.groovy`. (2认同)