zoukankan      html  css  js  c++  java
  • Junit测试错误:### Error building SqlSession

    错误代码:

    org.apache.ibatis.exceptions.PersistenceException:
    ### Error building SqlSession.
    ### The error may exist in com/jkw100/mybatis/mapper/PatientMapper.xml
    ### The error occurred while processing mapper_resultMap[BaseResultMap]
    ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jkw100.mybatis.mapper.PatientMapper.BaseResultMap
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:82)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:66)
    at com.jkw100.mybatis.mapper.PatientMapperTest.setUp(PatientMapperTest.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
    Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jkw100.mybatis.mapper.PatientMapper.BaseResultMap
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:115)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:95)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
    ... 25 more
    Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jkw100.mybatis.mapper.PatientMapper.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.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:167)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:118)
    at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:72)
    at org.apache.ibatis.binding.MapperRegistry.addMappers(MapperRegistry.java:97)
    at org.apache.ibatis.binding.MapperRegistry.addMappers(MapperRegistry.java:105)
    at org.apache.ibatis.session.Configuration.addMappers(Configuration.java:667)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:331)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:113)
    ... 27 more
    Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jkw100.mybatis.mapper.PatientMapper.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)
    ... 36 more

    Result Maps collection already contains value for com.jkw100.mybatis.mapper.PatientMapper.BaseResultMap 看到这句是因为mapper.xml文件中id为BaseResultMap这个名称重复 删除重复解决问题

    在用mybatis逆向工程自动生成mapper.xml的时候 如果不小心多运行了一次 那么在mapper.xml文件中的代码会多出一份 这样就会造成相同的id有两个或多个了 而相同的文件是不会多生成的

  • 相关阅读:
    Atitit alldiaryindex v1 t717 目录 1. Fix 1 2. Diary detail 1 2.1. Diary 1987---2016.12 1 2.2. Diary20
    Atitit web httphandler的实现 java python node.js c# net php 目录 1.1. Java 过滤器 servelet 1 1.2. Python的
    Atitit 网关协议cgi wsgi fcgi fastcgi 目录 1.1. CGI(common gateway unterface) 1 1.2. 2.1 WSGI: 1 1.3. 2.3
    Atitit gui的实现模式文本 dom ast 像素绘图api native 目录 1. Pl ast xml domAst 1 1.1. 简介 1 1.1.1. 【具体语法树】 2 2.
    Atitit 遍历文件夹目录解决方案与规范 attilax总结 1. 规范 2 1.1. 注意的不要同时改变文件夹内容,增删文件。这样获取到的目录list不会变化 2 1.2. 主义中文名称文件读写
    Atitit node.js自定义模块化 Function walkFileTree() exports.walkFileTree =walkFileTree 引用  Files=require
    Atitit node.js问题解决总结t99 目录 1.1. 找不到node程序 1 1.2. GBK编码问题 1 2. 按行读取gbk编码问题 2 2.1. 先写入txt utf8 encode
    Atitit io读取文件法 目录 1. 文件法 1 1.1. 异步读取文件: 1 1.2. 2.同步读取方法 1 1.3. 二进制读文件: 1 2. 读取api规范 1 3. Atitit 按照
    Atitit 按照行读取文件 目录 1.1. 类库'readline' 1 1.2. 类库C:workspacedataindexGenerNodejssdkioFileUtils.js
    Atitit sumdoc index 2019 v6 t56 .docx Atitit sumdoc index s99 目录 1. Zip ver 1 1.1. C:UsersAdminis
  • 原文地址:https://www.cnblogs.com/mrluotong/p/5889772.html
Copyright © 2011-2022 走看看