Rest java.net.ConnectException: при подключении двух приложений SpringBoot

Когда я попытался перейти из моего первого приложения Springboot в другое через RestTemplate, получая ошибку ниже от почтальона

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: Контроллер отдыха

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

person Arun    schedule 15.03.2019    source источник
comment
stackoverflow.com/a/40106981/7924858 перейдите по этой ссылке, которая может вам помочь   -  person abhinavxeon    schedule 15.03.2019


Ответы (1)


Пожалуйста, используйте приведенный ниже шаблон отдыха и попробуйте. Он должен работать

Результат ResponseEntity = restTemplate.exchange("http://localhost:8080/products", HttpMethod.GET, http , String.класс);

person NareshKumar S    schedule 15.03.2019