java.lang.IllegalArgumentException: Mapped Statements collection already contains value for xxx.xxx

标签: spring mvc mybatis
0人阅读 评论(0) 收藏 举报
分类:

初次配置mybatis,运行时出错,报错信息如下

java.lang.IllegalArgumentException: Mapped Statements collection already contains value for xxx.xxx.dao.methodname

后来发现原来是mybatis.xml文件中对mapper.xml文件引入了两次

以下是我的配置:

mybatis.xml配置sqlSessionFactory

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
    <property name="mapperLocations" value="classpath:sqlmap/*.xml"/>
</bean>

sqlMapConfig.xml引入mapper.xml

<mappers>
    <mapper resource="sqlmap/ResultSqlMap.xml"/>
</mappers>

错误原因:在sqlMapConfig.xml中已经引入了mapper.xml文件,在mybatis.xml中又引入了一次

<property name="mapperLocations" value="classpath:sqlmap/*.xml"/>

解决办法:去除其中一个引入即可

查看评论

异常java.lang.IllegalArgumentException: Mapped Statements collection already contains value for...

异常:java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.x...
  • gongzi2311
  • gongzi2311
  • 2016-08-31 16:33:27
  • 3554

Mapped Statements collection already contains value for ……

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFa...
  • qq_24936749
  • qq_24936749
  • 2017-09-25 00:39:34
  • 161

ibatis出现Mapped Statements collection already contains value for com.chong.model.AccountMapper.checkA

Mapped Statements collection already contains value for com.chong.model.AccountMapper.checkAccountEr...
  • lihaibo112924
  • lihaibo112924
  • 2014-11-07 14:35:53
  • 927

ibatis出现Mapped Statements collection already contains value for 错误

Mapped Statements collection already contains value for com.chong.model.AccountMapper.checkAccountEr...
  • sinat_29325027
  • sinat_29325027
  • 2016-05-04 15:41:43
  • 811

Mapped Statements collection already contains value for

Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection al...
  • tang_hai_bin
  • tang_hai_bin
  • 2015-08-27 11:03:08
  • 1749

mybatis 异常 Mapped Statements collection already contains value for .......

Error parsing Mapper XML  IllegalArgumentException: Mapped Statements collection already contains va...
  • saber872138
  • saber872138
  • 2016-03-30 17:42:06
  • 5256

Mapped Statements collection already contains value for com.*.*

遇到这种问题通常原因有两个: (1)相同的命名空间下有相同的id (2)sqlSessionFactory中配置了多个xml的地址。...
  • u012373281
  • u012373281
  • 2016-06-12 15:31:53
  • 1540

Mybatis出现Mapped Statements collection already contains value for

Mybatis出现Mapped Statements collection already contains value for  错误原因: 1.mapper中存在id重复的值 2.mappe...
  • ling_du
  • ling_du
  • 2016-06-14 17:55:18
  • 20580

mybatis Mapped Statements collection already contains value for

nested exception is java.lang.IllegalArgumentException: Mapped Statements collection already contain...
  • u010751309
  • u010751309
  • 2016-06-07 10:36:33
  • 641

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value f

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value f...
  • spencer_tseng
  • spencer_tseng
  • 2017-12-04 16:59:39
  • 103
    个人资料
    等级:
    访问量: 817
    积分: 64
    排名: 161万+
    文章分类
    文章存档