Hi Why I am getting this error when I am trying to test the methods in Controller class in SpringBoot Application?

java: cannot access org.springframework.web.bind.annotation.RequestMapping
bad class file: /C:/Users/lenovo/.m2/repository/org/springframework/spring-web/6.0.10/spring-web-6.0.10.jar!/org/springframework/web/bind/annotation/RequestMapping.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.

Hi @Sai_Chakra

From the output it seems like you are using the wrong version of Spring for the version of Java your project is using. Your project seems to be compiled with Java 8, and you are using Spring 6 which is only compatible with Java 17.
Therefore, I would recommend downgrading your Spring version to be compatible with the Java version you are using in your project. See compatible versions here
Let us know if you have any further questions.

Kind regards,
Jane @ Diffblue