spring cloud下配置服务问题

Description:

 

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

 

Reason: Failed to determine a suitable driver class

 

之前启动是正常的,出差之后还没动这个项目,突然之间启动不起来,按照翻译的情况,就是找不到数据库相关的配置,但是健康度检查项目是从配置文件中读出相关内容,为啥会没有数据库相关配置?

 

(1)查配置服务:

如果用如下url:

http://localhost:8081/order-a.yml

是能正常访问到相关的配置文件,但是如果要访问healch-check的配置文件:

spring cloud下配置服务问题_第1张图片

 

 

采用如下url:、

http://localhost:8081/health-check-dev.yml

http://localhost:8081/health-check-proc.yml

http://localhost:8081/health-check.yml

值均为:{}

 

说明很可能就是config服务的问题,说明很可能是没有更新或者有其他情况,我先进行更新试试:

http://localhost:8081/actuator/bus-refresh

这个注意,8081对应的是配置中心服务,而且要发出post请求,然后发现确实是有值的。

 

(2)查看日志

重新启动服务,发现还是报这个错。没有找到相关数据库配置,那么有没有可能还是这个问题,只是没有找到。重启了这个服务,然后仔细看了看日志:

2019-09-19 15:29:40.762 WARN 49376 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: {"timestamp":"2019-09-19T07:29:29.189+0000","status":500,"error":"Internal Server Error","message":"Cannot load environment","path":"/health-check/test"}

2019-09-19 15:29:40.762 INFO 49376 --- [ main] c.u.healthcheck.HealthCheckApplication : No active profile set, falling back to default profiles: default

 

果然是没有拉下配置!Could not locate PropertySource的意思就是没有spring cloud的配置。为什么没有找到呢?

访问服务器上的配置服务:

http://165host:8081/health-check.yml

果然返回结果为空。目前定位了问题在于config服务的问题!

 

(3)查看config运行情况

重启了config服务之后果然就没有问题了,事后再查查日志看下是什么原因造成的。

 

总结:首先定位问题,然后尝试各种可能的解决方案,最后根据问题再去推测整套框架的运行机制。

 

你可能感兴趣的:(spring,cloud)