小编Rah*_*hul的帖子

使用 Spring Rest Template 时,比较方法违反了其一般契约

我们的一个应用程序正在通过 Spring Rest 模板调用另一个应用程序。

HttpEntity<Object> httpEntity = new HttpEntity<>(null);
restTemplate.exchange(URL, HttpMethod.GET, httpEntity,String.class)
Run Code Online (Sandbox Code Playgroud)

我们尚未为请求显式设置任何标头。我们遇到以下异常:

Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeHi(TimSort.java:895)
    at java.util.TimSort.mergeAt(TimSort.java:512)
    at java.util.TimSort.mergeCollapse(TimSort.java:437)
    at java.util.TimSort.sort(TimSort.java:241)
    at java.util.Arrays.sort(Arrays.java:1512)
    at java.util.ArrayList.sort(ArrayList.java:1454)
    at java.util.Collections.sort(Collections.java:175)
    at org.springframework.http.MediaType.sortBySpecificity(MediaType.java:441)
    at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:691)
    at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:743)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:567)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:448)
Run Code Online (Sandbox Code Playgroud)

我们使用的Java版本是:1.8.0_45和Spring:4.1.6

如果有人能提供帮助那就太好了。如果需要,我很乐意提供更多详细信息。

期待中感谢。

java spring spring-mvc spring-rest

6
推荐指数
1
解决办法
1148
查看次数

Spring Boot 应用程序未启动且无异常

我正在使用 spring boot 版本:2.3.5.RELEASE,仅包含我要启动的主类。当我运行主类时,我收到以下消息,并且应用程序无法启动,没有任何错误。

2020-11-03 12:39:17.871  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : Starting HealthcheckApplication on INMLTCU6LVCG with PID 15426 (/Users/rahul/Documents/Rahul/Projects/healthcheck/target/classes started by rahul in /Users/rahul/Documents/Rahul/Projects/healthcheck)
2020-11-03 12:39:17.873  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : No active profile set, falling back to default profiles: default
2020-11-03 12:39:18.617  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : Started HealthcheckApplication in 1.353 seconds (JVM running for 1.806)

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

pom.xml 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion> …
Run Code Online (Sandbox Code Playgroud)

spring spring-boot

6
推荐指数
1
解决办法
8256
查看次数

标签 统计

spring ×2

java ×1

spring-boot ×1

spring-mvc ×1

spring-rest ×1