springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

错误如下

springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

  1. 分析一下:上面的描述是说没有配置数据源,未能确定合适的驱动程序类
  2. 原因:因为我在pom文件中添加了mybatis依赖,但是我没有配置连接数据库的url、用户名user 、和密码 passwordspringBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

3.解决方法:添加数据库连接配置

springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

4.再次启动日志没有报错问题解决

总结:1、如果在pom文件中添加了有关数据库的依赖时,需要在属性文件中配置连接该库的路径,用户名和密码.。

            2。如果添加了有关库的依赖但是又没有配置库的连接,只是仅仅解决上面的错误方法如下:

  此时我没有配置库的连接

springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

在启动类中添加

springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

再次启动springboot,日志没有报上面的错误!!

springBoot搭建时遇到的坑之Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded