spring cloud config 默认端口号

本文介绍了如何正确配置ConfigClient以访问ConfigServer指定的端口,而非默认的8888端口。通过在bootstrap.properties文件中进行设置,可以确保客户端能够正确连接到服务器上的指定端口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

无论你在 Config Server 中配置的端口号是什么,Config Client 启动时,都默认会去访问 Server 的 8888 端口。

解决方法:
在resources文件夹下,新建 bootstrap.properties 文件( bootstrap.yml 也可以)
这样,Client 启动后就会访问 Server 中配置的端口号了。

#配置在application.properties/yml都不行,必须是配置在bootstrap.properties/yml里面,否则还是会取本机的8888端口!!!
#官网原话:Bootstrap properties are added with high precedence, so they cannot be overridden by local configuration, by default.
server.port=8088
spring.application.name=config-client
eureka.client.service-url.defaultZone=http://localhost:8081/eureka/
spring.cloud.config.label=master
spring.cloud.config.profile=dev
# 这里必须配置为true,否则还是会取localhost:8888端口
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.service-id=config-server
#设为true,如果无法连接config server,启动时会抛异常,并停止服务
spring.cloud.config.failFast=true
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值