![](/img/trans.png)
[英]The dreaded Java SpringBoot app not connecting to MySQL with Docker-compose java.net.ConnectException: Connection refused
[英]Rest java.net.ConnectException : while connecting two SpringBoot application
當我試圖通過RestTemplate從我的第一個springboot應用程序消費到另一個應用程序時,從郵遞員獲得以下錯誤
請求URI: http:// localhost:8083 / template / getprodgsspringboot
"timestamp": "2019-03-15T10:02:39.168+0000",
"status": 500,
"error": "Internal Server Error",
"message": "I/O error on GET request for \"http://localhost:8080/products\": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect",
"path": "/template/getprodgsspringboot"
第一次春季啟動應用:休息控制器
@RequestMapping("/template/getprodgsspringboot")
public String getProductList() {
HttpHeaders headers=new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
HttpEntity<String> http=new HttpEntity<>(headers);
return resttemplate.exchange("http://localhost:8080/products",HttpMethod.GET,http,String.class).getBody();
}
第二個Spring啟動應用程序:Rest控制器
//GET Method of rest webservice
@RequestMapping("/products")
public ResponseEntity<Object> getMethod(){
System.out.println("My GET http method");
retu
請使用下面的resttemplate並試一試。 它應該工作
ResponseEntity result = restTemplate.exchange(“ http:// localhost:8080 / products ”,HttpMethod.GET,http,String.class);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.