Exception in Rest Template : Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/log/LogDelegateFactory

Exception in Rest Template : Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/log/LogDelegateFactory

我代码中的方法:

public static <T> ResponseEntity<T> get(String url, HashMap<String,String> parameters, HashMap<String,String> headers, Class<T> responseType){
        System.out.println(url);
        return new RestTemplate().exchange(
            String.format("%s%s",url, toQueryString(parameters)),
            HttpMethod.GET,
            toHttpEntity(headers), responseType);
    }

在请求 Rest Template 的新对象时,它给了我下面的异常 -->new RestTemplate():

线程“主”中的异常java.lang.NoClassDefFoundError:org/springframework/core/log/LogDelegateFactory 在 org.springframework.http.HttpLogging.forLog(HttpLogging.java:68) 在 org.springframework.http.HttpLogging.forLog姓名(HttpLogging.java:57) 在 org.springframework.http.client.support.HttpAccessor.(HttpAccessor.java:54) 在 org.springframework.http.client.support.InterceptingHttpAccessor.(拦截HttpAccessor.java:45) 在 org.springframework.web.client.RestTemplate.(RestTemplate.java:137)

依赖于 pom.xml

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.2.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.11.0</version>
        </dependency>

您的类路径中需要 spring 核心。

尝试添加

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.2.8.RELEASE</version>
</dependency>