• mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap--转


    转自:http://blog.csdn.net/tan3739/article/details/7555665

    Exception in thread "main" Java.lang.ExceptionInInitializerError
     at com.test.Test.main(Test.java:12)
    Caused by: org.apache.ibatis.exceptions.PersistenceException: 
    ### Error building SqlSession.
    ### The error may exist in com/mapper/PetMapper.xml
    ### The error occurred while processing mapper_resultMap[BaseResultMap]
    ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mapper.PetMapper.BaseResultMap
     at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
     at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:32)
     at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:16)
     at com.util.SessionFactory.<clinit>(SessionFactory.java:21)
     ... 1 more
    Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mapper.PetMapper.BaseResultMap
     at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:85)
     at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:69)
     at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:30)
     ... 3 more
    Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mapper.PetMapper.BaseResultMap
     at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:97)
     at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:73)
     at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:255)
     at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:83)
     ... 5 more
    Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.mapper.PetMapper.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

    后来在CSDN上下载了个可以直接运行的eclipse 项目,再与之前的项目对比,好像也没什么不同。最后使绝招:代码对比工具,发现生成的PetMapper.xml多了几百行!!!

    原来是我在运行时没有把之前已经生成的PetMapper.xml删除掉,再次生成代码时,又附加了上去!所以在运行代码生成之前,要把以前已经生成的xml文件清掉,以妨出错。

  • 相关阅读:
    WEB之CSS3系列笔记
    WEB之HTML5 系列笔记
    WEB之CSS系列笔记
    WEB 之 HTML 系列笔记
    npm安装(install)出现EPROTO: protocol error, symlink 解决方法
    笔记本电脑联网时没有WIFI列表选项可选
    Windows系统中下载Earthdata数据 2
    matlab cell
    【Linux系统】开启TFTP服务
    【Linux】搭建交叉编译环境
  • 原文地址:https://www.cnblogs.com/huhuuu/p/6234801.html
Copyright © 2020-2023  润新知