I encountered an error today. Result Maps collection already contains value for...
The error message is as follows:
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.java.zxf.dao.CountLoginTriedTimesDao.BaseResultMap at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120) at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92) at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:466) ... 65 more Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.java.zxf.dao.CountLoginTriedTimesDao.BaseResultMap at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:802) at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:774) at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:556) at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:217) at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:285) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244) at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116) ... 67 more
To the effect that the result set already exists in my CountLoginTriedTimesDao.xml
I went to the xml to have a look. Sure enough, there are two BaseResultMaps; in fact, there are not only two BaseResultMaps, but all the methods of adding, deleting, modifying and checking have double copies, just delete the duplicates.
More:
So why does this happen?
I used mybatis to reverse engineer the relevant mapping files, and I didn't find any duplicate content when I first generated them?
After thinking about it carefully, it is because I modified the table structure of the database after the first generation, and then regenerated it again;
When generating the second time, instead of deleting the first generated class and xml file, I ran it directly, and it was successful. The prompt was that these files were all overridden. A new one is added after the original;
Solution:
1. The quicker and easier way is to delete the file you generated for the first time, and then generate the file for the second time;
2. To analyze the source code, modify the source code or write plug-ins by yourself, you can refer to this article:
https://my.oschina.net/u/137785/blog/736372