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

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

客户端的bootstrap.yml配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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:xxxx-12xxx56@accp.xxx.net:8786/eureka/

出现的问题如下:

1
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文件的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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地址的时候,第一个配置生效,程序里确实第二个配置生效,尴尬…………

  • 作者: Sam
  • 发布时间: 2018-09-15 23:46:48
  • 最后更新: 2019-12-09 23:03:26
  • 文章链接: https://ydstudios.gitee.io/post/29fad61b.html
  • 版权声明: 本网所有文章除特别声明外, 禁止未经授权转载,违者依法追究相关法律责任!