我能够从以下 docker 文件将我的项目停靠在 Spring Boot 中:
FROM openjdk:7-jdk-alpine
ARG JAR_FILE=target/edms-influx-device-fixer-1.2.1.jar
COPY ${JAR_FILE} edms-influx-device-fixer-1.2.1.jar
ENTRYPOINT ["java","-jar","edms-influx-device-fixer-1.2.1.jar"]
但是当我尝试使用 docker 命令运行时: docker run -p 8085: 8085 name project
采取这个例外:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:808)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:443)
at java.net.URLClassLoader.access$100(URLClassLoader.java:65)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
我声明我的 JAVA_HOME 环境变量指向 jdk-14.0.2
如果在我的 docker 文件中我使用: openjdk:8-jdk-alpine 我得到这个异常:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/xxxx/xxxx/xxxx/App 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
我该如何解决这个异常?