为什么对RestTemplate postForEntity()的调用未返回?

时间:2019-11-18 10:28:59

标签: spring-boot post return resttemplate

当我向REST API提交请求时,对restTemplate.postForEntity(...)的调用不会返回。后续的System.out。不会执行,并且骗子不会停止。可能导致这种现象的原因以及如何解决?

ResponseEntity<?> crmResponse = null;
if( crmContactId == null) {
    crmResponse = crmRestTemplate.postForEntity(request, mapper.writeValueAsString(crmApiModel), Object.class);
} else  {
    crmResponse = crmRestTemplate.postForEntity(MessageFormat.format(request, crmContactId.toString()), mapper.writeValueAsString(crmApiModel), CrmApiModel.class);
}
System.out.println("crmResponse: " + crmResponse);

使用的CrmApiModel类:

public class CrmApiModel implements Serializable {

    private List<CrmApiModelProperty> properties = new ArrayList();

    public void addProperty(final CrmApiModelProperty property) {
        properties.add(property);
    }

//    @JsonProperty("properties")
    public List<CrmApiModelProperty> getProperties() {
        return properties;
    }

    public void setProperties(final List<CrmApiModelProperty> properties) {
        this.properties = properties;
    }

}

和CrmApiModelProperty类:

public final class CrmApiModelProperty<K, V> {

    private final K property;
    private V value;

    public CrmApiModelProperty(K property, V value) {
        this.property = property;
        this.value = value;
    }

    public K getProperty() {
        return property;
    }

    public V getValue() {
        return value;
    }
}

我也不例外...一无所有。我什至尝试捕获Throwable,但调试器也不会在那里停止。

0 个答案:

没有答案