您可以使用聚合器 - 微服务模式,但不能使用ZUUL。让Zuul成为无国界的门户。 聚合器微服务应该有这样的客户端代码
public String getProductTitle() { String response = null; try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpGet httpGet = new HttpGet("http://localhost:51515/information"); try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { response = EntityUtils.toString(httpResponse.getEntity()); } } catch (IOException e) { LOGGER.error("Exception caught.", e); } return response; } }
请看看 https://github.com/iluwatar/java-design-patterns/tree/master/aggregator-microservices