下文讲述一次 SpringBoot启动报错 Failed to determine a suitable driver class

Java-问题王 Java经验 发布时间:2021-08-17 14:53:54 阅读数:5388 1
今天配置文件中的本地数据库调整为云服务器的数据库地址时,重新启动出现以下错误,
  Description:

Failed to configure a DataSource: 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).
那么该如何处理此异常,下文将笔者的处理步骤分享如下:

步骤2

检查配置文件是否正确
配置文件名字是不是application-xxx.yml
application.yml是否激活指向XXX.yml

步骤2

application.properties中的数据库相关配置是否有误 驱动也要检查
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://【ip】:【端口】/【数据库名】?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=***
spring.datasource.password=***

步骤3

pom.xml文件中是否有依赖冲突
如引入了两个mysql驱动
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

本文链接: https://www.Java265.com/JavaJingYan/202108/1629183650725.html

最近发表

热门文章

好文推荐

Java265.com

https://www.java265.com

站长统计|粤ICP备14097017号-3

Powered By Java265.com信息维护小组

使用手机扫描二维码

关注我们看更多资讯

java爱好者