1

奇妙なこと...

バインディング定義 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 での呼び出しは成功です。

org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity
4

2 に答える 2

0

このメールスレッドにはいくつかの情報があるようです。

于 2009-10-20T13:51:28.390 に答える
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 用に) 再度コンパイルしたためです。そのため、複数のバインディング定義がありました...

于 2009-10-21T11:38:30.497 に答える