grails3.3 升级grails4 问题解决

 

 

升级教程

需要注意,如果引入插件,需要确认查看插件版本,有需要升级的要升级版本,否则各种问题

需要注意:

grails3.3 升级grails4 问题解决_第1张图片

需要手动在build.gradle中添加相关依赖包

 

如果出现执行报错:

grails3.3 升级grails4 问题解决_第2张图片

则手动将gradle包从3.5升级到gradle5就可以了,即:

grails3.3 升级grails4 问题解决_第3张图片

更改为

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

再运行 :

./gradlew wrapper --gradle-version 5.0

如果出现以下报错,则:

grails3.3 升级grails4 问题解决_第4张图片

需要修改build.gradle

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:7.0.0"
        classpath "org.grails.plugins:views-gradle:1.2.9"
        classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
    }
}

grails3.3 升级grails4 问题解决_第5张图片

需要把初始化数据放到service里面,然后引用,其实也就是需要有事务

如果是service报错,需要在service上添加事务注解

@Transactional

grails3.3 升级grails4 问题解决_第6张图片

注意:

升级Grails4.0.1后,可能启动时卡主,卡在:compileGroovy,如图:

grails3.3 升级grails4 问题解决_第7张图片

或者

grails3.3 升级grails4 问题解决_第8张图片

接着你们会发现风扇呼呼呼,,,,最后,内存溢出

运行:grails compile --verbose

19:22:43.308 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'compiler daemon' started
19:22:44.264 [DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Native-platform posix files integration is not available. Continuing with fallback.
19:22:45.397 [LIFECYCLE] [org.gradle.process.internal.health.memory.MemoryManager]
19:22:45.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 6195093504}
19:22:45.397 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 6195093504}
19:22:45.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:22:48.341 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 312475648}
19:22:50.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 6082039808}
19:22:50.396 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 6082039808}
19:22:50.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:22:52.007 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
19:22:52.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:22:52.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:22:52.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:22:52.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:22:52.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:22:52.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:22:53.342 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 363855872}
19:22:55.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 6093733888}
19:22:55.396 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 6093733888}
19:22:55.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:22:45.319 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger]
19:22:45.319 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :compileGroovy
19:22:57.686 [INFO] [org.gradle.api.internal.tasks.compile.JdkJavaCompiler] Compiling with JDK Java compiler API.
19:22:58.339 [LIFECYCLE] [org.gradle.process.internal.health.memory.MemoryManager]
19:22:58.339 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 357564416}
19:23:00.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 5980852224}
19:23:00.396 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 5980852224}
19:23:00.396 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:23:02.007 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
19:23:02.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:23:02.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:23:02.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:23:02.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:23:02.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:23:02.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:23:03.342 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 350748672}
19:23:05.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 5909340160}
19:23:05.397 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 5909340160}
19:23:05.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:23:08.342 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 464519168}
19:23:10.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 5804036096}
19:23:10.397 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 5804036096}
19:23:10.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:23:12.007 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
19:23:12.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:23:12.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:23:12.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:23:12.009 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:23:12.010 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
19:23:12.010 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
19:23:13.398 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 439353344}
19:23:15.398 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 5803118592}
19:23:15.398 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 5803118592}
19:23:15.398 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:23:18.342 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 439353344}
19:23:20.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17017151488, Free: 5803638784}
19:23:20.397 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17017151488, Free: 5803638784}
19:23:20.397 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 477626368, Committed: 330825728}
19:23:22.006 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
19:23:22.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
19:23:22.008 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.

一直在重复,直到内存溢出,

解决办法:官方回复

grails3.3 升级grails4 问题解决_第9张图片

  1. Set the following properties in gradle.properties

.gradle.properties

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx1024M
  1. In build.gradle file set the forkOptions for compileGroovy task as:

.build.gradle

compileGroovy.groovyOptions.forkOptions.jvmArgs = ['-Xmx1024m']

idea启动报错,

grails3.3 升级grails4 问题解决_第10张图片

但是,直接Application.groovy里面启动是可以的

grails3.3 升级grails4 问题解决_第11张图片

个人感觉解决方式有点勉强,但是应该有更好的解决办法,没办法,技不如人,自己又找不到问题所在,只能先用着了,,,哎(技不如人,技不如人,技不如人

 

你可能感兴趣的:(grails,spring,boot,groovy)