cf 推送失败 java 版本不匹配
cf push failed java version mismatch
我正在尝试将“spring-music”演示应用程序推送到我本地的开发云平台,但出现以下错误。当我 运行 命令“cf logs spring-music --recent”时,我得到以下输出。
2020-10-21T00:41:39.96+0300 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -Xmx408076K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=128499K
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR Exception in thread "main" java.lang.UnsupportedClassVersionError: org/cloudfoundry/samples/music/Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.defineClass1(Native Method)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.access0(URLClassLoader.java:74)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.run(URLClassLoader.java:369)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.run(URLClassLoader.java:363)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.security.AccessController.doPrivileged(Native Method)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
注意这个:
Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
您已经使用 Java 11
的编译器编译了您的项目,该编译器为您提供字节码版本 55.0
;
您的主机是 运行 Java 8
,它运行字节码版本 52.0
。
你可以cross-compile your project to support older Java versions. See here怎么做。
虽然 也是正确的,但您可能想要做的只是使用 Java 11 到 运行 您的应用程序。
您可以告诉 Java buildpack 您想要安装 Java 11 而不是默认的(在我写这篇文章时),即 Java 8.
运行 cf set-env <app-name> JBP_CONFIG_OPEN_JDK_JRE '{jre: { version: 11.+ }}'
针对您的应用程序或将该环境变量添加到您的 manifest.yml。然后 cf restage
您的应用。 Java buildpack 会看到它并自动为您安装 Java 11。
我正在尝试将“spring-music”演示应用程序推送到我本地的开发云平台,但出现以下错误。当我 运行 命令“cf logs spring-music --recent”时,我得到以下输出。
2020-10-21T00:41:39.96+0300 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -Xmx408076K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=128499K
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR Exception in thread "main" java.lang.UnsupportedClassVersionError: org/cloudfoundry/samples/music/Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.defineClass1(Native Method)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.access0(URLClassLoader.java:74)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.run(URLClassLoader.java:369)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.run(URLClassLoader.java:363)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.security.AccessController.doPrivileged(Native Method)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
2020-10-21T00:41:40.64+0300 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
注意这个:
Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
您已经使用 Java 11
的编译器编译了您的项目,该编译器为您提供字节码版本 55.0
;
您的主机是 运行 Java 8
,它运行字节码版本 52.0
。
你可以cross-compile your project to support older Java versions. See here怎么做。
虽然
您可以告诉 Java buildpack 您想要安装 Java 11 而不是默认的(在我写这篇文章时),即 Java 8.
运行 cf set-env <app-name> JBP_CONFIG_OPEN_JDK_JRE '{jre: { version: 11.+ }}'
针对您的应用程序或将该环境变量添加到您的 manifest.yml。然后 cf restage
您的应用。 Java buildpack 会看到它并自动为您安装 Java 11。