设置restTemplate 不抛出异常 拿到原始接口返回值
作者:互联网
// 设置restTemplate 不抛出异常
restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
@Override
public void handleError(ClientHttpResponse clientHttpResponse) throws IOException {
// 只要重写此方法,不去抛出HttpClientErrorException异常即可
HttpStatus statusCode = clientHttpResponse.getStatusCode();
log.error("错误码::[{}]",statusCode);
}
});
标签:clientHttpResponse,抛出,restTemplate,接口,设置,返回值,异常,statusCode 来源: https://blog.csdn.net/m0_56738320/article/details/121682171