2016-03-28 52 views
1

我已經看過這個鏈接,但不能得出一個解決我的問題:JAXB binding - "unable to honor this conversion customization"無法兌現定製JAX

我有這樣的XML

<xs:simpleType name="auditory_stimuli"> 
    <xs:restriction base="xs:boolean"/> 
</xs:simpleType> 

其中我使用這個定製:

<xs:simpleType name="auditory_stimuli"> 
<xs:restriction base="xs:boolean"> 
    <xs:annotation> 
     <xs:appinfo> 
      <jaxb:javaType name="java.lang.Boolean"/> 
     </xs:appinfo> 
    </xs:annotation> 
</xs:restriction> 

然而,當我運行XJC,我得到這個例外

Specified javaType customization is not used. 

有沒有人看到我在做什麼錯?

回答

0

<xs:annotation>其餘的綁定定義應該在<xs:simpleType>定義內,而不是在<xs:restriction>之內。

試試這個..

<xs:simpleType name="auditory_stimuli"> 
    <xs:annotation> 
     <xs:appinfo> 
      <jaxb:javaType name="java.lang.Boolean"/> 
     </xs:appinfo> 
    </xs:annotation> 
    <xs:restriction base="xs:boolean"/> 
</xs:simpleType> 

對於類似的事情,請參見下面的.. https://docs.oracle.com/javase/tutorial/jaxb/intro/custom.html#bnbch