you might be facing the below exception in the recent versions of Spring boot that class file has wrong version 61.0, should be 52.0
Exception:
Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile[m [1m(default-compile)[m on project [36mspring-api-gateway-demo[m: [1;31mCompilation failure[m
[ERROR] [1;31m/D:/sts/workspace/spring-api-gateway-demo/src/main/java/com/javasavvy/apigateway/SpringApiGatewayDemoApplication.java:[3,32] cannot access org.springframework.boot.SpringApplication[m
[ERROR] [1;31m bad class file: C:\Users\jayaramp.m2\repository\org\springframework\boot\spring-boot.0.4\spring-boot-3.0.4.jar(org/springframework/boot/SpringApplication.class)[m
[ERROR] [1;31m class file has wrong version 61.0, should be 52.0[m
[ERROR] [1;31m Please remove or make sure it appears in the correct subdirectory of the classpath.
Solution:
Spring Boot 3.0 does not support java 1.8 and requires minimum version of Java 17.0.
The following are possible reasons and please try to fix if your spring boot configurations matches any one:
- Your eclipse or STS JDK version is 1.8 and you are using Spring Boot 3.0. The solution is to upgrade or configure JDK to 17.0 in your STS to fix the issue
- You are using JDK 1.8 but configuring Spring cloud to 4.x which requires 17.0. The solution is if you are going to stick with JDK 1.8 and lower than 17 then configure Spring Cloud jars to 3.x
- Check Eclipse or STS compiler version.
- If you are using Spring boot 3.0 then compiler should be 17
- If you are using spring boot 2.x.x versions then check maven dependencies for spring boot and cloud both.
<properties> <java.version>1.8</java.version> <spring-cloud.version>2021.0.5</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>
Thanks.