MyBatis
1.XML命名错误
Wrong namespace. //错误的命名空间
Expected 'com.itheima.Mapper.UserMapper' //预期是'com.itheima.Mapper.UserMapper'
but found 'com/itheima/Mapper/UserMapper' //但实际是'com/itheima/Mapper/UserMapper'
XML的 namespace的内容中,不要用" / "来分割地址, 要用" . "
2.XML与注解冲突
Caused by: java.lang.IllegalArgumentException:
//报错原因是 IllegalArgumentException(非法参数异常):
Mapped Statements collection already contains value for com.itheima.Mapper.UserMapper.findAll
//映射语句集合中已包含 com.itheima.Mapper.UserMapper.findAll 的值
please check com/itheima/Mapper/UserMapper.xml and com/itheima/Mapper/UserMapper.java (best guess)
//请查看com/itheima/Mapper/UserMapper.xml和com/itheima/Mapper/UserMapper.java
在XML和接口中有相同的SQL语句时候会报错
要保证UserMapper.xml里面带<select>、<insert>、<update>、<delete>标签的ID是唯一的,相同的ID会报错
如果在UserMapper.java里定义了一个SQL,就不要再在UserMapper.xml文件中定义ID相同的SQL语句
3.XML和Mapper中的SQL语句格式
报错显示在执行注入操作时候,在数据库表
SchoolHeiMa.java里找不到startDate这个字段,导致无法执行注入
但是表中是有的,
这时候要去查看SchoolHeiMaMapper.java或者SchoolHeiMaMapper.xml的定义的SQL句式,查看当中的代码
在目前的startDate和endDate里面的"Date"前面加上下横线" _ "
就像后面的create_Time和update_Time一样. 保持一致这样就会正常注入