奇怪的事情......
我有一个绑定定义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,映射就会成功通过。如果我调用REST使用绑定user-composite-entity.xml,我会得到下一个错误:
org.jibx.runtime.JiBXException: Multiple bindings defined for class UserCompositeEntity
现在奇怪的事情(对我来说)。如果我从user-wrapper.xml中删除<include path="user-composite-entity.xml" />
,请执行以下操作:
- 使用user-composite-entity.xml调用是成功的,
- 使用user-wrapper.xml调用我收到错误:
org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity
答案 0 :(得分:0)
This email thread似乎有一些信息。
答案 1 :(得分:0)
现在如何工作:我再也没有user-wrapper.xml,而user-composite-entity.xml看起来像这样:
<binding>
<include path="core-wrapper.xml" />
<include path="core-composite-entity.xml" />
<include path="user-entity.xml" />
<mapping name="users" class="UserWrapper" extends="CoreWrapper">
<structure map-as="CoreWrapper" usage="optional" />
<collection field="users" usage="optional" >
</collection>
</mapping>
<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中包含user-composite-entity.xml之前,JiBX再次编译它(对于user-wrapper.xml)。这就是为什么有多个绑定定义...