JiBXException:为类定义了多个绑定
奇怪的事情...
我有一个绑定定义 user-wrapper.xml:
<binding>
<include path="core-wrapper.xml" />
<include path="user-composite-entity.xml" />
<mapping name="users" class="UserWrapper" extends="CoreWrapper">
<structure map-as="CoreWrapper" usage="optional" />
<collection field="users" usage="optional" item-type="UserCompositeEntity">
</collection>
</mapping>
</binding>
接下来我有这个绑定定义 user-composite-entity.xml (包含在上层文件中):
<binding>
<include path="core-composite-entity.xml" />
<include path="user-entity.xml" />
<mapping name="user" class="UserCompositeEntity" extends="CoreCompositeEntity">
<structure map-as="CoreCompositeEntity" />
<structure field="userEntity" usage="optional" />
<structure field="meta" marshaller="UserMetaHashMapper" unmarshaller="UserMetaHashMapper" usage="optional" />
</mapping>
</binding>
现在,如果我调用使用绑定 user-wrapper.xml 的 REST ,映射成功通过。如果我调用使用绑定 user-composite-entity.xml 的 REST,我会收到下一个错误:
org.jibx.runtime.JiBXException: Multiple bindings defined for class UserCompositeEntity
现在奇怪的事情(对我来说)。如果我从 user-wrapper.xml 中删除
会像这样: - 使用 user-composite-entity.xml 调用成功, - 使用 user-wrapper.xml 调用我收到错误:
org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity
Strange thing...
I have a binding definition user-wrapper.xml:
<binding>
<include path="core-wrapper.xml" />
<include path="user-composite-entity.xml" />
<mapping name="users" class="UserWrapper" extends="CoreWrapper">
<structure map-as="CoreWrapper" usage="optional" />
<collection field="users" usage="optional" item-type="UserCompositeEntity">
</collection>
</mapping>
</binding>
Next I have this binding definition user-composite-entity.xml (included in upper file):
<binding>
<include path="core-composite-entity.xml" />
<include path="user-entity.xml" />
<mapping name="user" class="UserCompositeEntity" extends="CoreCompositeEntity">
<structure map-as="CoreCompositeEntity" />
<structure field="userEntity" usage="optional" />
<structure field="meta" marshaller="UserMetaHashMapper" unmarshaller="UserMetaHashMapper" usage="optional" />
</mapping>
</binding>
Now, if I call REST which uses binding user-wrapper.xml, mapping goes successfully through. If I call REST which uses binding user-composite-entity.xml I get the next error:
org.jibx.runtime.JiBXException: Multiple bindings defined for class UserCompositeEntity
Now the strange thing (for me). If I remove from user-wrapper.xml <include path="user-composite-entity.xml" />
goes a like this:
- call with user-composite-entity.xml is a succes,
- call with user-wrapper.xml I get the error:
org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此电子邮件线程似乎有一些信息。
This email thread seems to have some information.
现在如何工作:我不再有 user-wrapper.xml,而 user-composite-entity.xml 看起来像这样:
问题是,因为在我在 user-wrapper.xml 中包含 user-composite-entity.xml 和JiBX 再次编译它(针对 user-wrapper.xml)。这就是为什么有多个绑定定义......
How it works now: I don't have user-wrapper.xml anymore and user-composite-entity.xml looks like that:
The problem was, because before I in user-wrapper.xml included user-composite-entity.xml and JiBX compiled it again (for user-wrapper.xml). That's why there were multiple binding definitions...