Код: Выделить всё
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.boot.test.json.JacksonTester;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.nio.file.Paths;
@JsonTest
public class JacksonInjectExample {
private static final String filePath = "test.json";
private static final String JSON = String.format(String.valueOf(Paths.get(filePath)));
@Autowired
private JacksonTester jacksonTester;
@Configuration
public static class TestConfiguration {...}
@BeforeClass
static public void setSystemProperties() throws IOException {...}
@Test
public void test() throws IOException {...}
}
Код: Выделить всё
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.boot.test.json.JacksonTester;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Код: Выделить всё
java: cannot access org.springframework.beans.factory.annotation.Autowired
bad class file: /C:/Users//.m2/repository/org/springframework/spring-beans/6.0.2/spring-beans-6.0.2.jar!/org/springframework/beans/factory/annotation/Autowired.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.
Использование Java 11, установленного в JAVA_HOME. .
Что я пробовал:
- Обновить JDK до Java 11.
< ли>дает: версия openjdk "11.0.17" 18 октября 2022 г. LTSКод: Выделить всё
java -version
- Обновите проект в IntelliJ для работы с Java 11.
- Удалить папку .idea.
- Недействительные кеши
Подробнее здесь: https://stackoverflow.com/questions/746 ... e-55-0-sic