【发布时间】:2018-01-14 07:13:54
【问题描述】:
我正在尝试通过restTemplate 在Spring Boot 微服务之间的docker 发出rest 请求,但我收到错误消息。
docker-compose.yml:
api:
image: api-service
container_name: api-service
restart: always
depends_on:
- product
ports:
- 8081:8080
links:
- product:product
environment:
- SERVICE_PORT_PRODUCT=8083
product:
image: product-service
container_name: product-service
restart: always
ports:
- 8083:8080
Exception日志:
ERROR 1 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://product:8083/api/products/": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)] with root cause
java.net.ConnectException: Connection refused (Connection refused)
看起来正确:
对“http://product:8083/api/products/”的 POST 请求
为什么它不起作用?
【问题讨论】:
标签: docker spring-boot resttemplate