Macos sdkman安装了Grails4.0.4,现在grails已损坏,无法启动

Macos sdkman安装了Grails4.0.4,现在grails已损坏,无法启动,macos,grails,sdkman,Macos,Grails,Sdkman,我安装了一些较旧版本的grails(3.3.8),并尝试使用sdkman安装较新版本(4.0.4)。安装成功了,但grails现在完全崩溃了。我还从oracle网站的dmg中将java更新为14。基本上,圣杯现在已经完全破碎了。有没有办法解决这个问题 mac 10.14.4 $ sdk version SDKMAN 5.7.3+337 $ sdk current java Not using any version of java $ java -version java ver

我安装了一些较旧版本的grails(3.3.8),并尝试使用sdkman安装较新版本(4.0.4)。安装成功了,但grails现在完全崩溃了。我还从oracle网站的dmg中将java更新为14。基本上,圣杯现在已经完全破碎了。有没有办法解决这个问题

mac 10.14.4

$ sdk version
  SDKMAN 5.7.3+337

$ sdk current java
  Not using any version of java

$ java -version
  java version "14.0.2" 2020-07-14
  Java(TM) SE Runtime Environment (build 14.0.2+12-46)
  Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

$ sdk current
  Using:
  groovy: 2.5.8

$ grails --version
  | Grails Version: 3.3.8
  | Groovy Version: 2.4.15
  | JVM Version: 14.0.2

$ sdk install grails
Downloading: grails 4.0.4
In progress...
######################################################################## 100.0%
Installing: grails 4.0.4
Done installing!
Setting grails 4.0.4 as default.

$ sdk current
 Using:
 groovy: 2.5.8

 $ grails --version
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
    at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
    at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
    at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
    at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
    at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:209)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:107)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
    at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
    at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
    at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
    at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:124)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:346)
    at java.base/java.lang.Class.newInstance(Class.java:604)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:257)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:110)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
    at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
    at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
    at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
我猜我可以尝试破解路径等,以修复

这是我当前的.bash_配置文件:

vi .bash_profile

export JAVA_HOME=`/usr/libexec/java_home`
export GRAILS_HOME=/Users/xx/dev/grails-3.3.8

export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
export PATH=$PATH:$GRAILS_HOME/bin

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
export GRADLE_HOME=/Users/xx/dev/gradle-5.1.1
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
PATH="${PATH}:/Users/xx/dev/flutter/bin"
PATH=$PATH:$GRADLE_HOME/bin


# Cassandra
if [ -d "/appz/cassandra" ]; then
    export PATH="$PATH:/appz/cassandra/bin"
fi

export PATH

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/simonh/.sdkman"
[[ -s "/Users/xx/.sdkman/xx/sdkman-init.sh" ]] && source "/Users/xx/.sdkman/bin/sdkman-init.sh"
~                                       
这很奇怪,为什么grails home仍然是3.3.8,而sdkman安装并使4.0.4成为当前版本?为什么它不编辑路径?我应该将gradle设置为什么版本?我如何回到java 8,因为我认为java 14中存在导致grails出现问题的bug?

好的,找到了答案

首先,我必须手动修复java版本

要执行此操作,请转到

 $ /usr/libexec
 $ ./java_home -V
这将输出一个或多个版本:

14.0.2, x86_64: "Java SE 14.0.2"    /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
1.8.0_131, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
现在编辑我们的.bash_配置文件,并用您想要的版本替换JAVA_主行,或者是整个版本(1.8.0_131),或者只是主要版本(1.8):

现在,当您打开一个新窗口并执行“java-version”时,您将获得1.8,而执行“grails-version”时,我最终将获得4.0.4

奇怪的是,仅仅改变JAVA_主页不应该影响路径上的内容,但似乎是这样。i、 当我输入“JAVA”时,仅仅设置JAVA_HOME不应该影响运行哪个版本的JAVA,但它确实会影响。i、 在muy bash_概要文件中没有“PATH=$PATH:$JAVA_HOME/bin”这样的行

14.0.2, x86_64: "Java SE 14.0.2"    /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
1.8.0_131, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
 export JAVA_HOME=`/usr/libexec/java_home -v 1.8`