关键错误提示代码
2020-07-25 14:29:37.269 ERROR 7556 --- [ restartedMain] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
场景
如题搭建SpringCloud微服务项目的配置中心,方便其它项目统一配置,并将配置推送大github上。
关键配置
application.yml
server:
port: 3344
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: git@github.com:EzerbelCN/springcloud-config.git #github上仓库的名字
search-paths:
- springcloud-config
label: master
eureka:
client:
service-url:
dafaultZone: http://eureka7001.com:7001/eureka/
错误锁定
debug查了很久,最终锁定到,直至错误抛出,程序并没有从yml中正确读取到的eureka服务的地址:7001,而是使用了默认的地址端口:8761。
尝试解决
将eureka相关配置提前
server:
port: 3344
eureka:
client:
service-url:
dafaultZone: http://eureka7001.com:7001/eureka/
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: git@github.com:EzerbelCN/springcloud-config.git #github上仓库的名字
search-paths:
- springcloud-config
label: master
问题解决
端口末尾不应该加 /
正确格式
server:
port: 3344
eureka:
client:
service-url:
dafaultZone: http://eureka7001.com:7001/eureka
spring:
application:
name: cloud-config-center
cloud:
config:
server:
git:
uri: git@github.com:EzerbelCN/springcloud-config.git #github上仓库的名字
search-paths:
- springcloud-config
label: master