2017-08-09 101 views

回答

0

您可以在同一個包中使用以下類作爲示例(註解爲@XmlRootElement)來覆蓋命名空間。


@XmlRootElement(name = "Root" ,namespace = "com.foo") 
public class Foo{ 
     ... 
} 

@XmlRootElement(name = "Root" ,namespace = "com.bar") 
public class Bar{ 
     ... 
} 

+0

這是兩種不同的命名空間的兩個不同XML根元素富和酒吧,但我想要一個XML根元素的兩個不同的命名空間讓我們說只爲Foo。 – Kanan

+0

你不能使用一個類來做到這一點。你必須在@XmlRootElement(name =「Bar」,namespace =「com.bar」)上創建另一個類並使用'name'屬性' – Xstian

+0

我的主要問題是https://stackoverflow.com/questions/45583409/ how-can-i-have-two-different-endpoint-with-different-namespace-and-same-jaxb-cla。它會更清楚我想要什麼。 – Kanan

相關問題