美文网首页我爱编程
报错,Result Maps collection alread

报错,Result Maps collection alread

作者: rockops | 来源:发表于2018-04-10 10:42 被阅读217次

环境: spring boot + mybatis
报错: Result Maps collection already contains value for xxx

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <mappers>
        <mapper resource="mapper/HelloMapper.xml"/>
    </mappers>
</configuration>

将mapper.xml删除,报错找不到mapper,证明这个mapper.xml是生效的。将mapper.xml的内容全部删除,写了一个最简单的<select>,发现还是报错,这说明跟mapper.xml本身是没有关系的。

折腾了2个小时,终于搞明白了是怎么回事。
原来在spring boot的application.properties中,配置了

mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapper-locations=classpath*:mapper/*.xml

这样相当于mapper的配置被配置了两遍,把mybatis-config.xml中的mappers部分删除,单测终于跑通。
spring boot的这个配置省的每次都要把xml写到mybatis-config.xml里边了

相关文章

网友评论

    本文标题:报错,Result Maps collection alread

    本文链接:https://www.haomeiwen.com/subject/upyghftx.html