我正在使用Spring Cloud Eureka Server和Config Server作为Discovery First,我的问题是:
当它在eureka服务器中自带的服务注册表时,它返回的配置服务器URL是 http://}:8888 的 http://LOCALHOST:8888 ,并且在其他服务器中托管的所有其他服务都无法找到其配置 .
日志行:
从服务器获取配置:http:// localhost:8888
我可以做任何配置来解决它吗?
配置服务器的application.yml是这样的:
server:
port: 8888
spring:
application:
name: configserver
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: /opt/config_dir
eureka:
client:
serviceUrl:
defaultZone: http://10.111.22.33:8761/eureka,http://10.111.33.44:8761/eureka
配置客户端bootstrap.yml是这样的:
spring:
application:
name: show-service
profiles:
active: dev
cloud:
discovery:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: http://10.111.22.33:8761/eureka,http://10.111.33.44:8761/eureka
1 回答
默认情况下,禁用Discovery First Bootstrap . 您在配置客户端应用程序中缺少一些属性 - 使用发现来查找配置服务器URL和配置服务器名称(service-id) .
更多:https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html#discovery-first-bootstrap