常见的restTemplate操作
1 | //三种方式 xxForObject、xxForEntity、exchange |
https请求报错
1 | Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://ecs.gac.com.cn:3351/ecs-console/api/bill/searchBillCount": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target |
处理方法
1 | RestTemplate restTemplate = new RestTemplate(new HttpsClientRequestFactory()); |