我想在我的基於RESTEasy的web應用程序中啓用JAXB註釋支持,並向我提供了這篇文章(http://wiki.fasterxml.com/JacksonJAXBAnnotations)。我能夠得到jackson-xc.jar,但我看不到如何註冊annotation introspector。目前,RESTEasy會自動序列化我的JSON響應,下面哪裏適合?目前,RESTeasy會自動序列化JSON對象。使用Jackson JSON庫和JAXB註釋
包括傑克遜-XC罐子,其中包含org.codehaus.jackson.xc.JaxbAnnotationIntrospector 註冊此註釋內省
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
// make deserializer use JAXB annotations (only)
mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
// make serializer use JAXB annotations (only)
mapper.getSerializationConfig().setAnnotationIntrospector(introspector);
好的。這樣的包裝是由RESTeasy完成的,因爲即使使用JAXB註釋,傑克遜也不這樣做;但是一些框架可以幫助確定在根級別綁定哪種類型。對於它的價值,這樣的包裝很容易處理簡單的包裝類,或使用java.lang.Map;所以這可能不需要使用@XmlRootElement。但可能有其他原因使用它。 – StaxMan 2011-01-21 04:56:57