一,问题
在使用restTemplate时候本地返回结果为401 Unauthorized: [no body],但是使用postman直接测试远程地址是可以的,如下图
二、分析
restTemplate的日志返回信息不完整,需要配置restTemplate返回的详细信息。在构建restTemplate的时候使用下列方法。
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
三、结果
我这边错误返回结果为少了一些包。在pom中引入即可。