我使用docker compose来运行我所有的微服务.对于每项服务,我给它一个简短的主机名.
version: '2'
services:
config:
image: springbox-config-server
restart: always
ports:
- "8890:8890"
discovery:
image: springbox-eureka
restart: always
ports:
- "8763:8763"
Run Code Online (Sandbox Code Playgroud)
因此,在我的微服务中,我必须使用其短主机名来定位配置服务器.
spring:
application:
name: myservice
cloud:
config:
uri: http://config:8890
fail-fast: true
Run Code Online (Sandbox Code Playgroud)
但是,当我在没有docker的IDE中本地运行它们时,无法解析短主机名.
所以我正在寻找一种解决方案,根据我的环境定位不同的配置服务器.