下面是restController。我正在尝试点击 JsonPlaceholder api,它在浏览器和邮递员中给出响应,但是当我尝试通过 restemplate 访问 url 时,它显示以下错误。“https://jsonplaceholder.typicode.com/users”的 GET 请求出现 I/O 错误:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径;嵌套异常是 javax.net.ssl.SSLHandshakeException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径
@RestController
public class CowinController {
@Autowired
private RestTemplate restTemplate;
@RequestMapping(path = "/cowin")
public RestTemplate getData()
HttpHeaders headers = new HttpHeaders();
String jsonPlaceholder = **"https://jsonplaceholder.typicode.com/users";**
HttpEntity<String> requeEntity = new HttpEntity<String>(headers);
ResponseEntity<Object> responseEntity = restTemplate.exchange(jsonPlaceholder,HttpMethod.GET,requeEntity,Object.class);
Object response = responseEntity.getBody();
}