SpringCloud项目报错:Failed to configure a DataSource

遇到这个错误的时候,本地能启动,git上的代码跟本地一样,然后jenkins构建,都没问题,jar包启动查看日志,就是报错!

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-24 09:00:42.251 ERROR 12296 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

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

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

这句话的错误是:配置数据源失败:未指定“url”属性,无法配置嵌入的数据源。

总的来说他,就是没有找到yml文件,或者yml文件有问题。

yml文件在config配置中心上,然后注入到注册中心Eureka中,这错误,应该就是没有找到config,读取不到yml文件。

所以检查一下,Eureka中注入的config地址,是不是服务器的地址,当时是本地的地址,所以找不到。

说出来你可能不信,本地的config注入到了服务器的Eureka里面了,那我在服务器上启动jar包,能找到yml文件,那才怪呢。

最后,重启服务器注册中心Eureka和config,然后重新jenkins构建,然后跑起来了。

希望能帮到大家。

猜你喜欢

转载自blog.csdn.net/weixin_44126152/article/details/109253848