本人在学习mybatis时候,测试一个案例出现的报错
1.Caused by: org.springframework.jdbc.cannotGetJdbcConnectionException Create breakpoint v Lmngma + : failed to obtain JDBc conection
实际是application.properties配置文件的,数据库url地址配置错误.
2.Access denied for user 'root'@'localhost'(using password: YES)
数据库密码错误
3.Unknown database 'db82'
找不到数据库
4.Table 'dbgl.tb userCaused by:java.sql.SOLSyntaxErrorException'doesn't exist
表不存在
5.No qualifying bean oftype 'com.itheima.boot06.mapper.UserMapper'
UserMapper依赖注入失败
该错误是 MySQL 的 SQL 语法错误,核心问题是 WHERE 关键字使用位置 / 上下文错误(如缺失 FROM 等前置子句、语法格式不对)。
在测试类上,要么保证测试类与主配置类(带 @SpringBootApplication 的类)同包 / 子包,让 @SpringBootTest 自动扫描;要么显式通过 @SpringBootTest(classes = 主配置类.class) 指定主配置类 。
因为用Long接收,当count没有返回值的时候默认值是null而不是0,所以需要加入null判断