springboot项目启动报找不到数据库连接配置url的错误

在学习springcloud入门案例的时候,启动服务工程发现报错:
1.问题记录:

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

Action:

Consider the following: If you want an embedded database (H2, HSQL or
Derby), please put it on the classpath. If you have database settings
to be loaded from a particular profile you may need to activate it (no
profiles are currently active).

Disconnected from the target VM, address: ‘127.0.0.1:2533’, transport:
‘socket’

2.问题分析:
看报错提示信息,显示未能读取到数据库连接的配置,所以应该查看配置文件格式是否正确

3.问题排查:
查看文件格式,yaml格式,配置项是否有错漏;
发现问题:
发现配置yaml和yml文件不能识别为绿叶配置文件,转换成properties文件却可以识别,如图:在这里插入图片描述
后来读了一下自动配置文件的配置项才发现,这里的配置文件必须以application结尾且全部小写才可以被识别,如图在这里插入图片描述
4解决问题:

改配置文件名为application后缀的即可。在这里插入图片描述


版权声明:本文为weixin_43965961原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。