1

I am getting this error when I try to start the Spring Boot Application:

java: cannot access org.springframework.boot.SpringApplication bad class file: /repository/org/springframework/boot/spring-boot/3.0.1/spring-boot-3.0.1.jar!/org/springframework/boot/SpringApplication.class class file has wrong version 61.0, should be 55.0 Please remove or make sure it appears in the correct subdirectory of the classpath.

I had a look at the below SO question and it looks like this error happens when the Spring Boot version is 3.0.1. But I dont have that version mentioned in the build.gradle file.

java: cannot access org.springframework.boot.SpringApplication bad class file

here is the build.gradle file portion:

    springCloudVersion = '2021.0.3'
    springBootPluginVersion = '2.7.6'
    sonarQubePluginVersion = '3.3'
    gatlingPluginVersion = '3.8.4'
    nebulaPublishingPluginVersion = '18.4.0'
    nebulaReleasePluginVersion = '16.0.0'
    jasyptSpringBootStarterVersion = '3.0.4'

Using Java 11.

I can also see that every time I build the project in IntelliJ, a spring boot 3.0.1 jar and its folder are created under the repository mentioned above ( even if I delete it). I can't see where is that version coming from. Any pointers will be greatly appreciated.

Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22
ljs
  • 495
  • 1
  • 8
  • 23
  • 1
    Spring Boot 3 need Java 17, ( https://spring.io/blog/2022/05/24/preparing-for-spring-boot-3-0 ) , `Upgrade to Java 17` – life888888 Jan 06 '23 at 05:25
  • Yes, I know that... The project uses Java 11 and that's why I have springBootPluginVersion = '2.7.6' in the build file. – ljs Jan 06 '23 at 05:40
  • Your Error Message is :`/repository/org/springframework/boot/spring-boot/3.0.1/spring-boot-3.0.1.jar!` – life888888 Jan 06 '23 at 06:00
  • 2
    Try `gradle clean` – life888888 Jan 06 '23 at 06:01
  • 1
    In IntelliJ, Gradle Tab, select your project , popmenu `Reload Gradle Project` – life888888 Jan 06 '23 at 06:06
  • 1
    In IntelliJ, Gradle Tab, select your project , popup menu `Analyze Dependencies`, check your Dependencies , spring boot version – life888888 Jan 06 '23 at 06:13
  • springboot plugin version (like other plugins) cannot be set from properties inside the `build.gradle` file AFAIK. can you share your build script section where you actually apply the springboot plugin ? something like ` plugins { id "org.springframework.boot" version "??????" } – M.Ricciuti Jan 06 '23 at 19:38
  • I have tried 'gradle clean', reloading the project, and analyzing dependencies many times. At some point. one of them worked and I dont get that error anymore .. Thank you @life888888 – ljs Jan 08 '23 at 22:54

1 Answers1

0

change the version as below

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>