Spring Cloud 服务启动连接 报:Fetching config from server at : http://localhost:8888

1.微服务报错原文:

2020-01-05 13:14:03.080  INFO 195216 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-01-05 13:14:04.227  INFO 195216 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2020-01-05 13:14:04.228  WARN 195216 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/service-hi/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2020-01-05 13:14:04.230  INFO 195216 --- [           main] c.e.e.EurekaClientApplication            : No active profile set, falling back to default profiles: default
2020-01-05 13:14:04.547  INFO 195216 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=2e19fb5c-dae4-32ce-beec-3c04e2b7fe27
2020-01-05 13:14:06.164  INFO 195216 --- [           main] c.e.e.EurekaClientApplication            : Started EurekaClientApplication in 5.6 seconds (JVM running for 7.7)

2.其中pom文件配置

server:
  port: 8762

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

spring:
  application:
    name: service-A

从 上面报错看出显示这个项目连接的server为默认的8888端口,并不是我项目配置文件中设定的8762端口;

通过错误日志,发现服务还是取的8888的配置中心的文件,这就涉及到了一个配置文件的优先级,在spring Cloud 中,有个 "启动上下文",用来加载ConfigServer里面的配置,默认的加载顺序为:bootstrap.*配置 --> 链接 configServer,加载远程配置 --> 加载application.* 配置。

3.解决方案

在pom.xml文件加入下面这个依赖,完美的解决问题

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
            <version>2.0.2.RELEASE</version>
</dependency>

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值