0

我们有两个微服务服务 1 和服务 2。在 Service1 中,我们有一个 PostMapping 并返回布尔值,如下所示。

@PostMapping
public boolean reset(){
    return true
}

当通过 restTemplate 交换方法从 Service2 消费时,它将以 XML 格式返回,如下所示。

boolean val = restTemplate.exchange(url, Post method, http entity with header, Boolean.class);

输出

<boolean>true</boolean>

我们期望在 resttemplate 调用中使用 JSON 格式,如果通过邮递员尝试,它将以 JSON 格式返回。

4

0 回答 0