grails dbm-generate-gorm-changelog错误

时间:2013-08-30 22:26:26

标签: grails database-migration

我正在尝试在grails中使用插件数据库迁移1.3.2但每次运行命令grails dbm-generate-gorm-changelog changelog.groovy时都会返回以下错误:

| Packaging Grails application.....
| Error Error executing script DbmGenerateGormChangelog: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'instanceTagLibraryApi': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsUrlMappingsHolder': Cannot resolve reference to bean 'urlMappingsTargetSource' while setting bean property 'targetSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMappingsTargetSource': Cannot resolve reference to bean 'org.grails.internal.URL_MAPPINGS_HOLDER' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.internal.URL_MAPPINGS_HOLDER': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsUrlMappingsHolder': Cannot resolve reference to bean 'urlMappingsTargetSource' while setting bean property 'targetSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMappingsTargetSource': Cannot resolve reference to bean 'org.grails.internal.URL_MAPPINGS_HOLDER' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.internal.URL_MAPPINGS_HOLDER': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? (Use --stacktrace to see the full trace)

应用程序编译和运行完美,我使用的grails版本是2.2.4。

我从.grails项目目录中删除了scriptCache目录。

这是BuildConfig.groovy

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
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.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
    legacyResolve false
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        grailsCentral()

        mavenLocal()
        mavenCentral()

        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        mavenRepo "http://snapshots.repository.codehaus.org"
        mavenRepo "http://repository.codehaus.org"
        mavenRepo "http://download.java.net/maven/2/"
        mavenRepo "http://repository.jboss.com/maven2/"
        mavenRepo "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

        runtime 'postgresql:postgresql:8.4-701.jdbc3'
        compile "org.grails:grails-core:2.2.2.BUILD-SNAPSHOT", { exclude "grails" }
        test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
    }

    plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.7.2"
        runtime ":resources:1.1.6"
        compile ":webxml:1.4.1"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.4"

        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.3.2"

        compile ':cache:1.0.0'

        compile ":twitter-bootstrap:2.1.1"

        compile ":functional-test:2.0.RC1"

        test(":spock:0.7") {
            exclude "spock-grails-support"
        }

        compile ":console:1.2"

        compile ":spring-security-core:1.2.7.3"

        compile ":quartz:1.0-RC8"
    }
}

有人可以指导我如何解决问题。

感谢。

1 个答案:

答案 0 :(得分:0)

我自己解决了这个问题,我做的是创建一个空项目并开始移动一些域文件,配置文件并尝试测试命令是否运行,每次我更改一些文件时我重新运行命令确保项目仍然有效,最后我将注意力集中在UrlMappings.groovy(在错误消息中我提到了一些URL_MAPPINGS_HOLDER)文件,因为我改变了一种方法,可以在映射之外获取grail应用程序(因为我'动态生成网址。)

错误映射看起来像这样。

//workaround to the grailsApplication outside mapping see: http://jira.grails.org/browse/GRAILS-8508
        def app
        "500"(view:"/error") {
          app = grailsApplication
        }

我解决了从那里删除grailsApplication的问题,现在命令运行完美。幸运的是,我们不再需要动态生成网址了。