Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

java: cannot access org.springframework.boot.SpringApplication
  bad class file: /C:/Users/xyz/.m2/repository/org/springframework/boot/spring-boot/3.0.0-SNAPSHOT/spring-boot-3.0.0-20220910.145857-773.jar!/org/springframework/boot/SpringApplication.class
    class file has wrong version 61.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
like image 899
sravan Avatar asked Nov 25 '25 09:11

sravan


2 Answers

The reason is Spring Boot 3 requires java 17, as stated in Preparing for Spring Boot 3.0.

class file has wrong version 61.0, should be 52.0

Referring to List of Java class file format major version numbers?. and similar question Class file has wrong version 52.0, should be 50.0 It indicates that you are using java 8 but the class file is compiled for java 17.

like image 59
samabcde Avatar answered Nov 28 '25 16:11

samabcde


Change your springboot version to the previous stable version.

Before :

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

After:

 <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.4</version>
    <relativePath/> <!-- lookup parent from repository -->
like image 38
Abdullah Ismail Avatar answered Nov 28 '25 17:11

Abdullah Ismail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!