bad class file class file has wrong version 61.0 should be 52.0

2024, Jan 07    

Problem

  • spring-web을 6.x로 올리고 maven install 또는 build, compile 중 발생
  • This error occurs when you change spring-web to version 6.x and then run maven install or build or compile.

Error

cannot access org.springframework.web.bind.annotation.PostMapping

bad class file: /org/springframework/spring-web/6.0.6/spring-web-6.0.6.jar
(org/springframework/web/bind/annotation/PostMapping.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.

Cause

  • java8로 되어있어서 문제..
  • The cause appears to be caused by setting the java8.

Solved

  • java를 17+ 로 올린다.
  • Change the java version to 17 or higher.