奇怪的事情...
我有一个绑定定义 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 中删除,<include path="user-composite-entity.xml" />
如下所示: - 使用 user-composite-entity.xml 调用成功, - 使用 user-wrapper.xml 调用我得到错误:
org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity