08:26:48.343 [main] DEBUG org.springframework.web.client.RestTemplate - HTTP GET http://localhost:8080/users/1
08:26:48.359 [main] DEBUG org.springframework.web.client.RestTemplate - Accept=[text/plain, application/json, application/*+json, */*]
08:26:48.391 [main] DEBUG org.springframework.web.client.RestTemplate - Response 404 NOT_FOUND
Exception in thread "main" org.springframework.web.client.HttpClientErrorException$NotFound: 404 Not Found
at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:85)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:102)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:778)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:736)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670)
at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:338)
at com.nijvelshare.contentcenter.service.ShareService.main(ShareService.java:24)
public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> entity = restTemplate.getForEntity(
"http://localhost:8080/users/1",
String.class
);
System.out.println(entity.getBody());
}
单独进入地址是可以访问的,不知道为什么出现404
面向未来微服务:熟练掌握Spring Cloud Alibaba
了解课程