Spring boot 启动报错-Reason Failed to determine a suitable driver class

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/buyaore_wo/article/details/80741159

启动异常

***************************

APPLICATION FAILED TO START

***************************

 

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).

 

 

配置:

spring.datasource.url = jdbc:mysql\://192.168.0.20\:1504/f_me?setUnicode=true&characterEncoding=utf8

spring.datasource.username = ...

spring.datasource.password = ...

 

问题分析:

在spring xml配置文件中引用了数据库地址 所以需要对:等进行转义处理

springboot如果没有指定spring.datasource.driver-class-name 会根据spring.datasource.url解析自动匹配驱动类, 而springboot不是xml方式配置的 所以spring.datasource.url不需要进行转义 ,加了转义之后对驱动解析就有问题了, 总之问题出在spring.datasource.url上,格式不正确spring自动解析不了(我这里是冒号前多了"\"转义符号)

 

解决问题:

修改配置

spring.datasource.url = jdbc:mysql://192.168.0.20:1504/f_me?setUnicode=true&characterEncoding=utf8

spring.datasource.username = ...

spring.datasource.password = ...

(注意其它spring.datasource.url格式错误问题也可能会导致同样的问题)

 

展开阅读全文

没有更多推荐了,返回首页