JiBXException:为类定义了多个绑定

发布于 2024-08-08 12:40:05 字数 1592 浏览 4 评论 0原文

奇怪的事情...

我有一个绑定定义 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别把无礼当个性 2024-08-15 12:40:05

此电子邮件线程似乎有一些信息。

This email thread seems to have some information.

国产ˉ祖宗 2024-08-15 12:40:05

现在如何工作:我不再有 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)。这就是为什么有多个绑定定义......

How it works now: I don't have user-wrapper.xml anymore and user-composite-entity.xml looks like that:

<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>

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文