zoukankan      html  css  js  c++  java
  • mybatis bug之org.apache.ibatis.exceptions.PersistenceException:

    详细报错信息:

    org.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database.  Cause: java.lang.IllegalArgumentException: findAllList is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)
    ### Cause: java.lang.IllegalArgumentException: findAllList is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)
    
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
        at com.ahd.Test.test.test(test.java:26)
        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:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
        at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    Caused by: java.lang.IllegalArgumentException: findAllList is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)
        at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:800)
        at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:631)
        at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:624)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
        ... 25 more

    解决总结:

             findAllList is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)

             findAllList在映射语句集合中是不明确的(尝试使用包含名称空间的全名,或者重命名其中一个条目)

    1. Persistence Exception 持久化 异常
    2. 持久化异常这种bug一般都是xml文件配置有错误,
    3. 测试时:主配置文件使用包名找xml文件,直接写映射文件名称没有问题,通过包扫描有问题
    <!--第一种:写映射文件的名字-->
    <!--
            <mapper resource="com/ahd/mapper/UserMapper.xml"></mapper>
    -->
            <!--第二种:写类名,一定要有个映射文件与之对应
            如果没有,那么在UserMapper要声明注解-->
            <!--<mapper class="com.gyf.mapper.UserMapper"></mapper>-->
    
            <!--第三种:可以写包名-->
            <package name="com.ahd.mapper"></package>

    4. *****(方法名) is ambiguous in Mapped Statements collection (try using the full name including the namespace, or rename one of the entries)

    本次错误是因为系统找不到findAllList对应的映射

    5.查看发现多个***mapper.xml都有这个方法,系统不知道使用的是哪一个,将findAllList方法加上路径即可

  • 相关阅读:
    简单的总结
    /bin/bash: sshpass: command not found
    ubuntu 16.04 忘记root密码
    ubuntu下QtCreator启动无响应问题解决
    TX1 文字界面启动与root用户自动登录设置
    qt线程睡眠
    TX2 默认root用户启动
    linux下使用文件IO监听GPIO中断
    Linux下指定线程的名字
    [Error] ISO C++ forbids comparison between pointer and integer
  • 原文地址:https://www.cnblogs.com/aihuadung/p/10783994.html
Copyright © 2011-2022 走看看