Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RunMojo




Asked on January 25, 2023
In my Spring application, I upgraded spring boot version to 3. The application starts to fail on mvn spring-boot:run

Error:

Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RunMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 60.0

How to resolve?

My pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies> 
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>



Replied on January 25, 2023
Check the error log. After compilation, your class file version is 60.0 that is Java 16. You need class file version 61 that is Java 17.

Spring boot 3.0 works on Java 17 or higher. You need to upgrade your Java version either 17 or higher.

Reference:
https://spring.io/blog/2022/11/24/spring-boot-3-0-goes-ga




Replied on January 25, 2023
I installed Java 17 and now my application is working. Thanks.

Write Answer










©2024 concretepage.com | Privacy Policy | Contact Us