我有两个Maven JAXB项目。
A:Main Maven JAXB存根XSD项目,包含BASKET.xsd
B:Maven JAXB存根想要将BASKET.xsd包装在自己的对象中的User-Project。
这导致两个对象工厂(不同的包),都声明了以下内容......
@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-plugin不在UserService ObjectFactory上生成方法createBasket(..)?
或者让CXF在两个ObjectFactoty类上接受两个相同的方法?
答案 0 :(得分:1)
我的解决方法是改变
<property name="singleJaxbContext" value="true"/>
到
<property name="singleJaxbContext" value="false"/>
e.g。在我的application-config.xml
中 <bean id="jaxbextprovider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
<property name="singleJaxbContext" value="false"/>
</bean>