Отдых java.net.ConnectException: при подключении двух приложений SpringBoot - PullRequest
0 голосов
/ 15 марта 2019

Когда я пытался получить данные из моего первого приложения 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"

Первая весенняя загрузка Приложение: контроллер Rest

@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

1 Ответ

0 голосов
/ 15 марта 2019

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

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

...