完整的错误报告如下:
Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mapper.xxxMapper.BaseResultMap
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:578)
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:551)
at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:356)
at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:138)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:231)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:201)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:196)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:93)
... 8 more
这个错误原因很简单,我们的mapper.xml文件一般是mybatis-generator自动生成的,这种错误是因为我们在二次生成相同名字、相同位置的文件时,内容重复生成了。把重复的内容或者id名字删除就能解决这个错误。