2015-07-10 18 views
8

file:JAXB generateElementProperty = false neden istenen etkiye sahip değil? Aşağıdaki bağları olan bir wsimport görevi koşuyorum

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

Ancak bu JAXBElement<String> yerine String ile sınıfları ile sonuçlanan mi getUserSummaryOrTypeOrLogLevel()

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "ConfigSLMAction", propOrder = { 
    "userSummaryOrTypeOrLogLevel" 
}) 
public class ConfigSLMAction 
    extends ConfigConfigBase 
{ 

    @XmlElementRefs({ 
     @XmlElementRef(name = "UserSummary", type = JAXBElement.class, required = false), 
     @XmlElementRef(name = "LogLevel", type = JAXBElement.class, required = false), 
     @XmlElementRef(name = "Type", type = JAXBElement.class, required = false) 
    }) 
    protected List<JAXBElement<String>> userSummaryOrTypeOrLogLevel; 
    @XmlAttribute(name = "name") 
    protected String name; 
    @XmlAttribute(name = "local") 
    protected Boolean local; 
    @XmlAttribute(name = "intrinsic") 
    protected Boolean intrinsic; 
    @XmlAttribute(name = "read-only") 
    protected Boolean readOnly; 
    @XmlAttribute(name = "external") 
    protected Boolean external; 

    /** 
    * Gets the value of the userSummaryOrTypeOrLogLevel property. 
    * 
    * <p> 
    * This accessor method returns a reference to the live list, 
    * not a snapshot. Therefore any modification you make to the 
    * returned list will be present inside the JAXB object. 
    * This is why there is not a <CODE>set</CODE> method for the userSummaryOrTypeOrLogLevel property. 
    * 
    * <p> 
    * For example, to add a new item, do as follows: 
    * <pre> 
    * getUserSummaryOrTypeOrLogLevel().add(newItem); 
    * </pre> 
    * 
    * 
    * <p> 
    * Objects of the following type(s) are allowed in the list 
    * {@link JAXBElement }{@code <}{@link String }{@code >} 
    * {@link JAXBElement }{@code <}{@link String }{@code >} 
    * {@link JAXBElement }{@code <}{@link String }{@code >} 
    * 
    * 
    */ 
    public List<JAXBElement<String>> getUserSummaryOrTypeOrLogLevel() { 
     if (userSummaryOrTypeOrLogLevel == null) { 
      userSummaryOrTypeOrLogLevel = new ArrayList<JAXBElement<String>>(); 
     } 
     return this.userSummaryOrTypeOrLogLevel; 
    } 
    ... 
    ... 
    ... 
} 

aşağıda girişi gösterildiği gibi Bu sınıfın oluşturulduğu xsd dosyası aşağıdaki gibidir:

<xsd:complexType name="ConfigSLMAction"> 
    <xsd:complexContent> 
     <xsd:extension base="tns:ConfigConfigBase"> 
      <xsd:choice maxOccurs="unbounded"> 
       <xsd:element name="UserSummary" minOccurs="0" maxOccurs="1"> 
        <xsd:simpleType> 
         <xsd:union memberTypes="tns:dmString tns:dmEmptyElement" /> 
        </xsd:simpleType> 
       </xsd:element> 
       <xsd:element name="Type" minOccurs="1" maxOccurs="1"> 
        <xsd:simpleType> 
         <xsd:union memberTypes="tns:dmSLMActionType tns:dmEmptyElement" /> 
        </xsd:simpleType> 
       </xsd:element> 
       <xsd:element name="LogLevel" minOccurs="0" maxOccurs="1"> 
        <xsd:simpleType> 
         <xsd:union memberTypes="tns:dmLogLevel tns:dmEmptyElement" /> 
        </xsd:simpleType> 
       </xsd:element> 
      </xsd:choice> 
      <xsd:attributeGroup ref="tns:ConfigAttributes" /> 
     </xsd:extension> 
    </xsd:complexContent> 
</xsd:complexType> 

Burada '

<plugin> 
    <groupId>org.jvnet.jax-ws-commons</groupId> 
    <artifactId>jaxws-maven-plugin</artifactId> 
    <version>2.3</version> 
    <executions> 
     <execution> 
      <id>wsimport-from-jdk</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>wsimport</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <wsdlFiles> 
      <wsdlFile>${basedir}/src/main/resources/wsdl/xml-mgmt.wsdl</wsdlFile> 
     </wsdlFiles> 
     <bindingFiles> 
      <bindingFile>${basedir}/src/main/resources/wsdl/bindings.xml</bindingFile> 
     </bindingFiles> 
     <keep>true</keep> 
     <verbose>true</verbose> 
     <extension>true</extension> 
     <vmArgs> 
      <vmArg>-Djavax.xml.accessExternalDTD=all</vmArg> 
      <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> 
     </vmArgs> 
    </configuration> 
</plugin> 

kimse bu neden oluyor ışık tutabilecek miyim

benim pom dosyasından Maven eklentisi s? JAXBElement<String> yerine String kullanmak istiyorum ve SO ve diğer yerlerde bulduğum herhangi bir şey, generateElementProperty=false'un çalıştığını ancak bunun olmadığını gösteriyor.

+0

tamam Ben de benzer bir soru bulundu: http://stackoverflow.com/questions/22513736/jaxb-avoid-jaxbelement ve sorun seçim öğesi ile. – hudi

cevap

8

orada ya foo veya bar elemanları oluşabilir bir xsd:choice ve onlar aynı tip ise JAXBElement zorunludur ile çoğaltılır. Basit bir String, hangi öğenin sıralanacağını işaretlemek için yeterli değildir.

JAXBElement

xsd:complexType adlı aynı olan iki küresel unsurlar varsa orada eleman nillable="true" ve minOccurs="0" ise yada de gereklidir.

1

Hataların JAXB'de olduğundan emin olmak için başka bir eklenti deneyebilir misiniz?

 <plugin> 
      <groupId>org.apache.cxf</groupId> 
      <artifactId>cxf-codegen-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>generate-sources-ais</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <defaultOptions> 
          <bindingFiles> 
           <bindingFile>${basedir}/src/main/resources/wsdl/binding/bindings.xml</bindingFile> 
          </bindingFiles> 
         </defaultOptions> 
         <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot> 
         <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot> 
         <includes> 
          <include>**/*.wsdl</include> 
         </includes> 
        </configuration> 
        <goals> 
         <goal>wsdl2java</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

ve

GÜNCELLEME bekliyor gibi çalıştığını: Projemizde kullandığımız doğru eklenti ok vardır

. Çünkü seçim elemanıdır. Muhtemelen this

+0

Aynı çıktıyı 'JAXBElement 'ile aldım ancak' -xjc-Xinheritance' eklentisini kullanamadım çünkü eklenti – conorgriffin

+0

hatası verdi. Sadece, binding.xml dosyasında kalıtım kullandığınızda ve sonra başka bir bağımlılığa ihtiyaç duyduğunuzda buna ihtiyacınız var. Ben xml – hudi

+0

güncellenecek Ben zaten arg çıktı, hala jaxws-maven-plugin' – conorgriffin

İlgili konular