昨日私はタイトルに投稿されたようなjavaを更新しましたが、JAXBはXMLをもう解析しません。すべてのオブジェクトは単にヌルですが、何も設定されていないようです。JAXBは1.8.0_77から1.8.0_121にJavaをアップデートした後アンマーシャリングしません
このPOJOを考える - 私は非整列化のためにこれを使用
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="ListMatchingProductsResult", propOrder={
"products"
})
@XmlRootElement(name = "ListMatchingProductsResult")
public class ListMatchingProductsResult {
@XmlElement(name="Products")
private ProductList products;
/**
* Get the value of Products.
*
* @return The value of Products.
*/
public ProductList getProducts() {
return products;
}
/**
* Set the value of Products.
*
* @param products
* The new value to set.
*/
public void setProducts(ProductList products) {
this.products = products;
}
/**
* Check to see if Products is set.
*
* @return true if Products is set.
*/
public boolean isSetProducts() {
return products != null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("products", products)
.toString();
}
}
ListMatchingProductsResponse
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ListMatchingProductsResponse", propOrder = {
"listMatchingProductsResult",
"responseMetadata"
})
@XmlRootElement(name = "ListMatchingProductsResponse")
public class ListMatchingProductsResponse {
@XmlElement(name = "ListMatchingProductsResult")
private ListMatchingProductsResult listMatchingProductsResult;
@XmlElement(name = "ResponseMetadata")
private ResponseMetadata responseMetadata;
@XmlAttribute(name = "xmlns")
private String xmlns;
public String getXmlns() {
return xmlns;
}
public void setXmlns(String xmlns) {
this.xmlns = xmlns;
}
/**
* Get the value of ListMatchingProductsResult.
*
* @return The value of ListMatchingProductsResult.
*/
public ListMatchingProductsResult getListMatchingProductsResult() {
return listMatchingProductsResult;
}
/**
* Set the value of ListMatchingProductsResult.
*
* @param listMatchingProductsResult The new value to set.
*/
public void setListMatchingProductsResult(ListMatchingProductsResult listMatchingProductsResult) {
this.listMatchingProductsResult = listMatchingProductsResult;
}
/**
* Get the value of ResponseMetadata.
*
* @return The value of ResponseMetadata.
*/
public ResponseMetadata getResponseMetadata() {
return responseMetadata;
}
/**
* Set the value of ResponseMetadata.
*
* @param responseMetadata The new value to set.
*/
public void setResponseMetadata(ResponseMetadata responseMetadata) {
this.responseMetadata = responseMetadata;
}
}
そしてListMatchingProductsResult:私がいないと私は思いビットが失わ
String s = getResult();
// s is the expected xml string
ListMatchingProductsResponse m = JAXB.unmarshal(new StringReader(s), ListMatchingProductsResponse.class);
log.info(m); // [email protected]
log.info(m.getListMatchingProductsResult()); // null
何らかの理由があるのを見てください。また、JAXBに関してchangeloに変更がありませんg。
私はここで間違っていますか?
次の答えは、私は今、自分のプロジェクトに、次の依存関係が含まれていたこれまで
JAXB Configuration was broken by upgrading from JDK 1.7 to JDK 1.8 u05 for collections
Unmarshalling jaxB doesn't work, objects null
Unmarshall with JAXB doesn't work
UPDATE
を自分の問題を解決していなかった
group: 'org.jvnet.jaxb2.maven2', name: 'maven-jaxb2-plugin', version: '0.13.1'
もう一度動作します。新しい質問 - それはなぜですか?何か不足している/ 121のJavaリリースのバグはありますか?
'maven-jaxb2-plugin'はコード生成のためのMavenプラグインです。あなたはコンパイルやランタイムの依存関係としてそれを含めるべきではありません。 – lexicore
@lexicore私はいくつかの異なるjaxb依存関係を試しましたが、どれもうまくいきませんでした。私はそれが意味をなさないが、私はなぜこれが再び動作するようにするのを知りたいのですか? – Michael
'maven-jaxb2-plugin'自体がJAXBライブラリに依存しています。だから、基本的にMavenプラグインからの依存関係を "継承"することになります。これを参照してください:http://stackoverflow.com/questions/26413431/which-artifacts-should-i-use-for-jaxb-ri-in-my-maven-project – lexicore