Mapper 与自身冲突? [英] The Mapper conflicts with itself?

查看:66
本文介绍了Mapper 与自身冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用带有两个 myBatis 映射器的应用程序运行 JBoss 服务器时收到一条消息

I have a message when trying to run the JBoss server with app with two myBatis mappers

XML fragments parsed from previous mappers already contains value for workSql

有趣的是,sql 元素 workSql 位于一个唯一的映射器中.并且只存在一次.我也通过文件搜索检查过.

The funny moment is that the sql element workSql is in one only mapper. And exists only once. I had checked that by file searching, too.

类似的问题,在MyBatis:从3.0.3升级到3.2.7时出错,关于消息

The similar problem, in MyBatis: Errors when upgrading to 3.2.7 from 3.0.3, about the message

Mapped Statements collection already contains value for com.foo.FooDao.java

是不同的,因为它不是关于 sql 元素,而是关于 Spring 上下文中引用的整个 MyBatis 映射器.而且它的收据也不适用于我的情况 - 我的映射器已经有了命名空间,但它们无济于事.

is different, for it is not about sql element, but about the whole MyBatis mapper referenced in Spring context. And the receipt for it won't work for my case, too - my mappers already have namespaces and they won't help.

推荐答案

似乎如果映射器没有准确命名,在某些情况下,MyBatis 会尝试多次读取它们,并且它们会与自己冲突.

It seems that if mappers are not exactly named, the MyBatis in some situations tries to read them more than once and they conflict with themselves.

收据是在 configuration.xml 文件中设置所有映射器:

The receipt was to set all mappers in the configuration.xml file:

<mappers>
    <mapper resource="amcssz/spr/srv/main/batis/ReportsMapper.xml"/>
    <mapper resource="amcssz/spr/srv/main/batis/SprMapper.xml"/>
</mappers>

所有冲突都消失了.

这篇关于Mapper 与自身冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆