2017-07-03 61 views
1

我有兩個Maven JAXB項目。JAXB錯誤:有多個映射。由於兩個對象工廠具有相同的Bean

答:主要的Maven JAXB存根XSD項目,這包含BASKET.xsd

B:想要包裝BASKET.xsd在自己的對象的Maven JAXB存根用戶項目。

這導致兩個對象的工廠(不同的包),這兩個聲明如下...

@XmlElementDecl(namespace = "http://www.bob.org/bob/namespace/", name = "Basket") 
public JAXBElement<BasketType> createBasket(BasketType value) { 
    return new JAXBElement<BasketType>(QNAME, BasketType.class, null, value); 
} 

這一代是通過這個插件做... org.jvnet.jaxb2.maven2 maven- JAXB2-插件 0.13.2

在應用程序啓動我得到CXF-RT-Frotnend-JAXRS 3.1.11給我一個錯誤...

017-07-03 14:38:54,613845801: WARN : [RMI TCP Connection(3)-127.0.0.1] [] org.apache.cxf.jaxrs.utils.ResourceUtils: No JAXB context can be created 
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
The element name {http://www.bob.org/bob/namespace/}Basket has more than one mapping. 
    this problem is related to the following location: 
     at public javax.xml.bind.JAXBElement com.bob.bean.ObjectFactory.createBasket(org.bob.BasketType) 
     at com.bob.bean.ObjectFactory 
    this problem is related to the following location: 
     at public javax.xml.bind.JAXBElement org.userservice.bean.ObjectFactory.createBasket(org.bob.BasketType) 

這是不是一個錯誤我一直到我從CXF 2.7.7升級到3.1.11

有誰知道是否有辦法讓maven-jaxb2插件不生成方法createBasket(.. .. )在UserService ObjectFactory上?

或者讓CXF接受兩個ObjectFactoty類中的兩個方法?

+0

你檢查這https://stackoverflow.com/questions/10795793/i-cant-understand-why-this-jaxb-illegalannotationexception-is-thrown – prasad

+0

是的,我已經讀過那個。 –

回答

0

我soloution是改變

<property name="singleJaxbContext" value="true"/> 

<property name="singleJaxbContext" value="false"/> 

例如在我的應用-config.xml中

<bean id="jaxbextprovider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"> 
    <property name="singleJaxbContext" value="false"/> 
    </bean> 
相關問題