cxf codegen-plugin生成JAXBElement列表,即使generateElementProperty = false也是如此

时间:2017-08-25 17:34:56

标签: java cxf jaxb2 cxf-codegen-plugin

我使用cxf-codegen-plugin wsdl2java和以下绑定文件:

<jaxb:bindings version="2.1"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<jaxb:bindings>
    <jaxb:globalBindings generateElementProperty="false">
    </jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>

我的问题是我的xsd

的以下部分
<xs:complexType name="clientType">
            <xs:sequence>
                <xs:element name="name" type="xs:string" minOccurs="0" />
                <xs:choice>
                    <xs:sequence>
                        <xs:element name="phone1" type="xs:string"
                                    minOccurs="1" />
                        <xs:element name="phon2" type="xs:string"
                                    minOccurs="0" />
                    </xs:sequence>
                    <xs:element name="phone2" type="xs:string"
                                minOccurs="1" />
                </xs:choice>
            </xs:sequence>
        </xs:complexType>

我仍然得到

列表
protected List<JAXBElement<String>> content;

我的ClientType类用

注释
@XmlElementRefs({
    @XmlElementRef(name = "name", type = JAXBElement.class, required = false),
    @XmlElementRef(name = "phone1", type = JAXBElement.class, required = false),
    @XmlElementRef(name = "phone2", type = JAXBElement.class, required = false)
})

编辑:codegen插件

<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
    <execution>
        <id>generate-sources</id>
        <phase>generate-sources</phase>
        <defaultOptions>
            <bindingFiles>
                <bindingFile>${basedir}/src/main/jaxb/bindings.xml</bindingFile>
            </bindingFiles>
            <noAddressBinding>true</noAddressBinding>
        </defaultOptions>
        <configuration>
            <sourceRoot>${basedir}/src/main/java</sourceRoot>
            <wsdlOptions>
                <wsdlOption>
                    <wsdl>${basedir}/src/main/resources/service.wsdl</wsdl>
                    <extraargs>
                        <extraarg>-server</extraarg>
                    </extraargs>
                </wsdlOption>
            </wsdlOptions>
        </configuration>
        <goals>
            <goal>wsdl2java</goal>
        </goals>
    </execution>
</executions>
</plugin>

有没有办法避免使用JAXBElement列表而不是String列表?

由于

0 个答案:

没有答案