Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource...

问题: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

1.首先根据报错datasource could be configured.所以我们先排查到application.properties文件中url配置文件是否正确,例如以下:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=123456

2.对比查看pom.xml文件是否引入mysql依赖和查看maven库中mysql版本是否和本地数据库mysql版本是否一致

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
     <!-- 使用最新的适配版本 -->
</dependency>

本地数据库版本
在这里插入图片描述

maven仓库中mysql版本
在这里插入图片描述

3.还有注意一点, 在XXXmapper.java文件用注解执行sql和xml只能选一种

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值