2013-10-03 1 views
0

나는이 link에서 간단한 xml 자습서를 테스트합니다. 이런 XML 파일을 변경합니다.PersistenceException - 단순 XML 비 직렬화에서 이름의 중복 주석

<example xmlns:ns1="http://www.blah.com/ns/a"> 
    <a> 
    <b> 
     <x>abc</x> 
     <ns1:x>blah</ns1:x> 
    </b> 
    </a> 
</example> 

및 다음 코드를 Example7 클래스에 추가합니다.

@Path("a/b") 
    @Element(name = "x") 
    private String x_; 

나는이 예외 PersistenceException : Duplicate annotation of name 'x' on field 'x'을 얻었다. 이 예외를 극복하는 방법을 알고 싶습니다.

감사합니다.

+1

적어도 다른 클래스의'x' 변수를 게시 할 수 있습니까? – ollo

답변

0

Example7 클래스 내에서 x 필드에 주석을 추가하여 ns1 네임 스페이스를 사용해야합니다.

@Element 
@Path("a/b") 
@Namespace(reference="http://www.blah.com/ns/a", prefix="ns1") 
private String x; 

corresponding section of Simple XML tutorial도 참조하십시오.