[英]Java runtime error in Spring Boot application
I a new to programming and learning Java.我是编程和学习的新手 Java。
I am trying to package a Java Spring Boot application.我正在尝试 package 一个 Java Spring 启动应用程序。 When I use the command "mvnw package" I get the following error:当我使用命令“mvnw package”时,出现以下错误:
/watchlist/WatchlistApplicationTests 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 /watchlist/WatchlistApplicationTests 已由更新版本的 Java 运行时(类文件版本 55.0)编译,此版本的 Java 运行时仅识别 ZA2F2ED4F8DC40061 文件版本 A2
From reading online, I learnt that there is an issue with me using older Java version.通过在线阅读,我了解到我使用较旧的 Java 版本存在问题。
File version 55.0 is Java 11 and version 52.0 is Java 8.文件版本 55.0 是 Java 11,版本 52.0 是 Java 8。
I tried updating the Java version using the "Check for updates program".我尝试使用“检查更新程序”更新 Java 版本。 So that is fine.所以这很好。
When I run the "java -version" command I get the following:当我运行“java -version”命令时,我得到以下信息:
openjdk version "11.0.8" 2020-07-14 LTS OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (build 11.0.8+10-LTS, mixed mode) openjdk version "11.0.8" 2020-07-14 LTS OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (build 11.0. 8+10-LTS,混合模式)
I then tried to change the project settings on Eclipse:然后我尝试更改 Eclipse 上的项目设置:
Java Build Path -> Libraries -> JRE System Library [jdk-15] Java 构建路径 -> 库 -> JRE 系统库 [jdk-15]
Java Compiler -> Compiler Compliance Level - 14 Java 编译器 -> 编译器合规级别 - 14
The POM file is a below: POM 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.openclassrooms</groupId>
<artifactId>watchlist</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>watchlist</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Not sure where I am going wrong.不知道我哪里出错了。
Its working fine with java 1.8.它与 java 1.8 一起工作正常。 use jvm 1.8 for development使用 jvm 1.8 进行开发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.