报错截图:
翻译:
Has been loaded by XML or SqlProvider, ignoring the injection of the SQL.
已由XML或SqlProvider加载,忽略SQL的注入。
环境版本:
- SpringBoot:v2.1.1.RELEASE
- MybatisPlus:3.0.6
我的代码:
dao层接口
@Repository("integralDao")
public interface IntegralDao extends BaseMapper<IntegralEntity> {
Integer selectCount();
}
Mapper
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.tfjybj.typing.provider.dao.IntegralDao">
<select id="selectCount" resultType="int">
SELECT
count(*)
FROM
`ty_integral`
WHERE
is_delete =0
</select>
</mapper>
解决办法:
给Dao层接口换个其他的名字就好了。
原因:
因为使用的是MybatisPlus,并且在Dao层继承了MybatisPlus的BaseMapper,使得他具有了一些默认方法,然后你写的dao层接口的名字,正好和mybatisplus自己封装的sql的名字重复了,所以才会出现这种问题。
下图是笔者截取的 com.baomidou.mybatisplus.core.mapper下的代码,图中的确红色框框的方法名字和我写的方法名字重复了,所以给出了红色提示。
感谢您的阅读,因为笔者能力有限,如有错误,还望各位大佬们,指点迷津