springboot中mybatis报错
java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.mao.mapper.BrMapper.Br
[Request processing failed; nested exception is java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.mao.mapper.BrMapper.Br] with root cause
原因
使用mybatis报错
java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.xxx.mapper.xxxMapper.xxx
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:853) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:605) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:344)
- 在mapper.xml文件中,将 resultType 和 resultMap 弄混淆。
这个原因一般报错的第一行后面都会有这样一句话 org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.xxx.xxx with root cause
注意:使用resultMap时,必须要有
如果是直接返回一个用户定义的实体类型,则要使用resultType,弄混淆就会报错。
检查写的Mapper文件是不是全部返回值错误,每一个都要检查 ,希望大家以后都不要再犯这种错误 !
- 在mapper.xml头部namespace引入错误。
这个namespace引入的mapper文件要和你的mapper.xml文件对应。