将 Grails 从 2.1.5 升级到 2.4.4

upgrading grails from 2.1.5 to 2.4.4

我正在尝试将我们的 grails 应用程序从 2.1.5 升级到 2.4.4。 我创建了一个新的 2.4.4 项目并从现有项目中复制了所有源代码。 java 从 7 到 8。

构建配置是

grails.servlet.version = "3.0" // 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.work.dir = "target/work"

grails.project.target.level = 1.8

grails.project.source.level = 1.8

//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolver = "ivy"

/*grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
//  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
*/

System.setProperty("logback.configurationFile", "${basedir}/grails-app/conf/logback-build.xml")


grails.project.dependency.resolution = {
    // inherit Grails' default dependencies

    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:

        // excludes 'ehcache'

        excludes 'grails-plugin-log4j' , 'log4j'

    }

    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'

    checksums true // Whether to verify checksums on resolve

  //  legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility


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

        grailsPlugins()
        grailsHome()
        grailsCentral()
        mavenCentral()
        mavenLocal()

        grailsRepo "https://grails.org/plugins"
        mavenRepo "http://repo.grails.org/grails/repo"
        mavenRepo "http://repo1.maven.org/maven2/"
        mavenRepo "https://repo1.maven.org/maven2/"
        mavenRepo "https://repo.grails.org/grails/plugins/"
        mavenRepo "http://repo.grails.org/grails/libs-releases/"
    
        // uncomment these 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/"
    }

    dependencies {
    
    runtime 'xalan:serializer:2.7.1'
    compile 'commons-net:commons-net:2.0'
    compile 'org.grails.plugins:logback:0.3.1'
//  runtime "ch.qos.logback:logback-core:0.9.29"
    
    
    compile 'org.springframework.ws:spring-ws:2.1.0.RELEASE'

    
    '

    runtime 'org.mariadb.jdbc:mariadb-java-client:2.2.4'
    compile 'org.grails.plugins:rendering:1.0.1-SNAPSHOT'
    //compile("mysql:mysql-connector-java:8.0.13")
    runtime 'mysql:mysql-connector-java:5.1.16'
    test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
}

plugins {
    // plugins for the build system only
    build ":tomcat:7.0.55"

    
    // plugins for the compile step
    compile ":scaffolding:2.1.2"
    compile ':cache:1.1.7'
    compile (":asset-pipeline:2.6.9") {

        excludes 'grails-plugin-log4j' , 'log4j'
    }

    // plugins needed at runtime but not for compilation
   runtime ":hibernate4:4.3.5.5" //":hibernate:3.6.10.18" // or "" :hibernate4:4.3.6.1
    
    
    runtime ":database-migration:1.4.0"
    //runtime ':database-migration:1.3.1'
    runtime ":jquery:1.11.1"
    
    compile ":spring-security-core:2.0.0"

    
    compile ":remoting:1.3"

    
    compile(":ws-client:1.0") {
        excludes "org.codehaus.woodstox:wstx-asl:3.2.8"
    }
    
    compile("org.grails.plugins:blueprint:1.0.2")
    compile("org.grails.plugins:executor:0.3")
    compile("org.grails.plugins:export:1.5")
    
    //  compile("org.grails.plugins:mail:1.0")
    //  compile("org.grails.plugins:mysql-connectorj:5.1.22.1")
        compile("org.grails.plugins:quartz:1.0.2")
    
        compile("org.grails.plugins:remote-pagination:0.3")
        compile("org.grails.plugins:rest:0.8")      
    //  compile 'org.grails.plugins:quartz:1.0.1'
    
    }
}

现在,当我尝试 运行 应用程序时,它说

 [localhost-startStop-1] ERROR  o.c.g.g.w.c.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_25]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
    ... 4 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': **Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'**; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
    ... 4 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
    ... 4 common frames omitted
Caused by: java.lang.NullPointerException: null
    ... 4 common frames omitted

你能告诉我如何解决这个错误吗?

从 Grails 2.1.5 升级到 2.5.5 或 2.5.6 将为您提供 Java 8 支持。我已经做过多次了。我也已经从 Grails 2 升级到 Grails 3,或者我现在建议使用 Grails 4。如果你打算从 Grails 2 到 3 或 4 进行更大的跳跃。我会跳过 Grails 3 而不是转到 Grails 4。做从 2 升级到 4 需要额外的时间,但从 Grails 2 升级到 3 的时间大约相同。最大的问题之一是您使用的插件不再受支持。即使对于 Grails 2.5.5 这可能是个问题,但对于 Grails 3 或 4 来说是一个更大的问题。

在这里,我发布了一些从 Grails 2 到 Grails 4 的智慧。

How to Upgrade Grails from Grails 2.4.4 to Grails 4.0.1?