在我的JAXB类中,我是否将@XmlElement注释放在私有(private)变量声明之上?@XmlElement(name="report_name")privateStringname;在二传手之上?@XmlElement(name="report_name")publicvoidsetName(Stringname){this.name=name;}还是setter/getter之上?@XmlElement(name="report_name")publicStringgetName(){returnname;}我已经通读了几本JAXB教程,但尚未找到一致的模式。
这就是我正在做的:@XmlType(name="foo")@XmlAccessorType(XmlAccessType.NONE)publicfinalclassFoo{@XmlElement(name="title")publicStringtitle(){return"hello,world!";}}JAXB提示:com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:2countsofIllegalAnnotationExceptionsJAXBannotationisplacedonamethodthatisnotaJAX
我有4个类(class)。Person类,以及抽象的ContactInformation,Phone和Address类对其进行扩展。@XmlRootElement@XmlAccessorType(XmlAccessType.NONE)publicclassPerson{@XmlElement(required=true,nillable=false)privateStringfirst;@XmlElement(required=true,nillable=false)privateStringlast;@XmlElementWrapper(name="contacts")@XmlEle
我收到以下错误:Ifaclasshas@XmlElementproperty,itcannothave@XmlValueproperty更新类:@XmlType(propOrder={"currencyCode","amount"})@XmlRootElement(name="priceInclVat")@XmlAccessorType(XmlAccessType.FIELD)publicclassPriceInclVatInfo{@XmlAttributeprivateStringcurrency;@XmlValueprivateStringcurrencyCode;privated
我有一个像这样通过JAXB的简单pojo注释类:publicclassMyPojoimplementsSerializable{privatefinalstaticlongserialVersionUID=1234L;@XmlElement(name="Type",required=true,defaultValue="none")@NotNullprotectedSeismicDataAcquisitionSystemTypetype;@XmlElement(name="IpAddress",required=true)@NotNull@Pattern(regexp="((1?[0-
我有这种情况@XmlType(name="",propOrder={"value"})@XmlRootElement(name="compound")publicclassCompoundextendsValue{@XmlElements({@XmlElement(name="simple",type=Simple.class),@XmlElement(name="compound",type=Compound.class)})protectedListvalue;//...}所以复合是简单和/或复合的列表。两者都从定义为Value扩展publicabstractclassValuei
我在将XML响应从服务转换为POJO时遇到异常。XML如下所示:这是我的XMLresponse.javax.xml.bind.UnmarshalException:unexpectedelement(uri:"",local:"ItemSearchResponse").Expectedelementsare我是这样使用它的:Documentresponse=getResponse(url);JAXBContextcontext=JAXBContext.newInstance(AmazonItem.class);UnmarshallerunMarshaller=context.creat
为什么这不可能?看起来很简单,但它的行为并不像预期的那样。总结:A类使用聚合的DataAbean,而B类(A类的子类)使用聚合的DataBbean(而DataB扩展了DataA)。我编写了这些测试类来可视化和解释我的问题:A类:packagetest;importjavax.xml.bind.annotation.XmlAccessType;importjavax.xml.bind.annotation.XmlAccessorType;importjavax.xml.bind.annotation.XmlElement;importjavax.xml.bind.annotation.X
当我向服务器发送SOAP请求时,它返回以下错误。我不确定如何配置unmarshaller,我将向多个web服务发送SOAP请求。WSDL是here.我访问了以下页面,但仍未找到解决方案。1,2,3java.lang.IllegalStateException:Nounmarshallerregistered.CheckconfigurationofWebServiceTemplate.atorg.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:406)ator
对于带有以下注释的Java代码:@JsonProperty(value="Contact")@NotNull(message="ContactUserorCompanyNameisrequired.")@Valid@XmlElements(value={@XmlElement(name="ContactUser",type=ContactUser.class,required=true),@XmlElement(name="CompanyName",type=String.class,required=true)})privateObjectcontactInfo;当我使用对象进行GE