简体   繁体   English

休息java.net.ConnectException:同时连接两个SpringBoot应用程序

[英]Rest java.net.ConnectException : while connecting two SpringBoot application

When i tried to consume from my first springboot application to another via RestTemplate getting below error from postman 当我试图通过RestTemplate从我的第一个springboot应用程序消费到另一个应用程序时,从邮递员获得以下错误

Request URI: http://localhost:8083/template/getprodgsspringboot 请求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"

First spring boot Application : Rest controller 第一次春季启动应用:休息控制器

@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();
}

Second Spring boot Application :Rest controller 第二个Spring启动应用程序:Rest控制器

//GET Method of rest webservice
@RequestMapping("/products")
public ResponseEntity<Object> getMethod(){
    System.out.println("My GET http method");
    retu

Please use the below resttemplate and give a try. 请使用下面的resttemplate并试一试。 It should work 它应该工作

ResponseEntity result = restTemplate.exchange(" http://localhost:8080/products ", HttpMethod.GET, http, String.class); ResponseEntity result = restTemplate.exchange(“ http:// localhost:8080 / products ”,HttpMethod.GET,http,String.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可怕的 Java SpringBoot 应用程序未通过 Docker-compose java.net.ConnectException 连接到 MySQL:连接被拒绝 - The dreaded Java SpringBoot app not connecting to MySQL with Docker-compose java.net.ConnectException: Connection refused 运行Web服务时出现java.net.ConnectException? - java.net.ConnectException while running webservice? java.net.ConnectException - java.net.ConnectException java.net.ConnectException - java.net.ConnectException SpringBoot + RabbitMQ抛出错误:java.net.ConnectException:连接被拒绝 - SpringBoot + RabbitMQ throwing error : java.net.ConnectException: Connection refused java.net.ConnectException:通过代理连接时连接超时 - java.net.ConnectException: Connection timed out while connecting through a proxy 弹性搜索:通过RestHighLevelClient连接时的java.net.ConnectException - Elastic search: java.net.ConnectException when connecting via RestHighLevelClient 连接到本地主机时出错:8060:java.net.ConnectException:连接被拒绝 - Error connecting to localhost:8060: java.net.ConnectException: Connection refused 休息客户端 java.net.ConnectException:连接超时:连接 - Rest client java.net.ConnectException: Connection timed out: connect 在我的应用程序上执行Ant构建时获取java.net.ConnectException - Getting java.net.ConnectException while performing Ant build on my application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM