Java JAXB没有生成合适的getter和setter方法。只有一个内容列表<;JAXBElement<&燃气轮机&燃气轮机;
我的JAXB生成了如下java类:Java JAXB没有生成合适的getter和setter方法。只有一个内容列表<;JAXBElement<&燃气轮机&燃气轮机;,java,jaxb,jaxb2,jaxb2-maven-plugin,Java,Jaxb,Jaxb2,Jaxb2 Maven Plugin,我的JAXB生成了如下java类: <pre> * <complexType name="StubCalculationPeriodAmount"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * &
<pre>
* <complexType name="StubCalculationPeriodAmount">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="calculationPeriodDatesReference" type="{http://www.fpml.org/2009/FpML-4-7}CalculationPeriodDatesReference"/>
* <choice>
* <sequence>
* <element name="initialStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
* <element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue" minOccurs="0"/>
* </sequence>
* <element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
* </choice>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StubCalculationPeriodAmount", propOrder = {
"content"
})
public class StubCalculationPeriodAmount {
@XmlElementRefs({
@XmlElementRef(name = "calculationPeriodDatesReference", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
@XmlElementRef(name = "finalStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
@XmlElementRef(name = "initialStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class)
})
protected List<JAXBElement<?>> content;
/**
* Gets the rest of the content model.
*
* <p>
* You are getting this "catch-all" property because of the following reason:
* The field name "FinalStub" is used by two different parts of a schema. See:
* line 14273 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
* line 14267 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
* <p>
* To get rid of this property, apply a property customization to one
* of both of the following declarations to change their names:
* Gets the value of the content 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 content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link StubValue }{@code >}
* {@link JAXBElement }{@code <}{@link StubValue }{@code >}
* {@link JAXBElement }{@code <}{@link CalculationPeriodDatesReference }{@code >}
*
*
*/
public List<JAXBElement<?>> getContent() {
if (content == null) {
content = new ArrayList<JAXBElement<?>>();
}
return this.content;
}
*
*
*
*列表中允许以下类型的对象
*{@link JAXBElement}{@code}
*{@link JAXBElement}{@code}
*{@link JAXBElement}{@code}
*
*
*/
公共列表>();
}
返回此.content;
}
此java类没有适当的getter和setter方法。我希望jaxb能够生成如下所示的java类:
<pre>
* <complexType name="StubCalculationPeriodAmount">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="calculationPeriodDatesReference" type="{http://www.fpml.org/2009/FpML-4-7}CalculationPeriodDatesReference"/>
* <choice>
* <sequence>
* <element name="initialStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
* <element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue" minOccurs="0"/>
* </sequence>
* <element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
* </choice>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StubCalculationPeriodAmount", propOrder = {
"content"
})
public class StubCalculationPeriodAmount {
@XmlElementRefs({
@XmlElementRef(name = "calculationPeriodDatesReference", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
@XmlElementRef(name = "finalStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
@XmlElementRef(name = "initialStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class)
})
protected List<JAXBElement<?>> content;
/**
* Gets the rest of the content model.
*
* <p>
* You are getting this "catch-all" property because of the following reason:
* The field name "FinalStub" is used by two different parts of a schema. See:
* line 14273 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
* line 14267 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
* <p>
* To get rid of this property, apply a property customization to one
* of both of the following declarations to change their names:
* Gets the value of the content 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 content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link StubValue }{@code >}
* {@link JAXBElement }{@code <}{@link StubValue }{@code >}
* {@link JAXBElement }{@code <}{@link CalculationPeriodDatesReference }{@code >}
*
*
*/
public List<JAXBElement<?>> getContent() {
if (content == null) {
content = new ArrayList<JAXBElement<?>>();
}
return this.content;
}
我不知道该怎么做。因为这个java类是自动生成的
我想得到InitialStub值,有人能帮我吗?谢谢
xsd模式:
描述存根计算周期的类型。
在初始存根的强制性规范和最终存根的可选规范或强制性最终存根之间选择组。
尝试从带注释的类生成模式,您将看到必须定义的模式以获得该类。xsd从何而来?你能控制它吗?您可以附加完整的xsd吗?从中生成类?@Andreas如何从注释类生成类?我正在使用Maven。那么我是否需要再次执行maven clean安装?这不起作用…@OndřejFischer嗨,我附加了这个模式模式对于直接映射到Java字段来说太复杂了,因为有两个同名的元素。因此,代码生成器返回到JAXBElement
列表,其中可能有两个名称相同、规格可能不同的值(例如minOccurs=“0”
与隐含的minOccurs=“1”
差异)。如果您想要生成干净的Java代码,那么您需要修改模式并放弃它当前指定的验证的一部分,只需将其设置为两个可选字段,即no
。
</xsd:complexType>
<xsd:complexType name="StubCalculationPeriod">
<xsd:annotation>
<xsd:documentation xml:lang="en">A type describing the Stub Calculation Period.</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:annotation>
<xsd:documentation xml:lang="en">Choice group between mandatory specification of initial stub and optional specification of final stub, or mandatory final stub.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="initialStub" type="Stub"/>
<xsd:element name="finalStub" type="Stub" minOccurs="0"/>
</xsd:sequence>
<xsd:element name="finalStub" type="Stub"/>
</xsd:choice>
</xsd:complexType>