45

Spring Cloud Config客户端报错:Could not locate PropertySource: I/O error on GET...

 5 years ago
source link: https://www.ydstudio.net/archives/88.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

今天在研究Spring Cloud Config配置中心,出了一个很让人恼火的问题,我先贴一下我的相关配置信息:

客户端的bootstrap.yml配置:

server:
  port: 9009

spring:
  application:
    name: admin-server
    profiles:
      active: dev
  cloud:
    config:
      name: admin-server-config
      label: master
      profile: dev
      discovery:
        enabled: true
        service-id: config-server

eureka:
  client:
    service-url:
      defaultZone: http://Eurexxxr:[email protected]:8786/eureka/

出现的问题如下:

Could not locate PropertySource: I/O error on GET request for "http://config-server:9008/admin-server-config/dev/master": Connection refused; nested exception is java.net.ConnectException: Connection refused

大致的意思是说"http://config-server:9008/admin-server-config/dev/master"这个链接不能够访问,可我试着访问一下,却是可以访问的,这就让我百思不得其解!于是乎百度google走起,在stackoverflow上倒是找到几条相关的问题,但是问题的解答方案都不是很靠谱!于是乎放弃答案的寻找,我就去菜市场买菜,毕竟晚饭还是要吃的!酒足饭饱之后我又来研究这个问题。按理说提示这种链接不能访问,就是hosts文件映射的问题(ps:配置中心config-server我部署在我阿里云博客上),可是那个链接确实可以直接访问的…………………………………………我就试着看看我的hosts文件,第一次我还没有看出问题,我不死心的又看第二次,总算让我发现了问题的所在,下面是当时hosts文件的内容:

# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
xx.78.xx.12     config-server
127.0.0.1       dev
127.0.0.1       search-provider
127.0.0.1       config-server
127.0.0.1       work.ydstudios.com
127.0.0.1       work.damei.com
127.0.0.1       work.gx.com
127.0.0.1       work.phpcms.com
127.0.0.1       work.typecho.com
127.0.0.1       work.seacms.com
127.0.0.1       work.dy360.net
127.0.0.1       work.btsearch.com
127.0.0.1       work.search.com
127.0.0.1       work.mm.com
127.0.0.1       work.duowan.com

不知道大家看出来没有?有两个ip指向了config-server,而且我发现这种配置,不同时候起作用的配置还不一样!

直接访问url地址的时候,第一个配置生效,程序里确实第二个配置生效,尴尬…………

最后更新于 2018-09-15 22:22:56 并被添加「spring cloud」标签,已有 1 位童鞋阅读过。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK