开发者

Best Practice for Serialize/Deserialize from Java to XML

开发者 https://www.devze.com 2022-12-31 07:00 出处:网络
What is the most appropriate way to serialize Java Classes to XML? I tried JAXB, but it has issues with Interfaces and Generics. What so开发者_高级运维lution is least intrusive but scalable?I\'ve alwa

What is the most appropriate way to serialize Java Classes to XML? I tried JAXB, but it has issues with Interfaces and Generics. What so开发者_高级运维lution is least intrusive but scalable?


I've always had positive experiences with XStream:

http://x-stream.github.io/tutorial.html#to-xml

As you can see, it's simple to use.

I haven't actually used XStream with Generics (I've only ever used it for simple JavaBean type classes), but Google seems to suggest it handles them without problems. e.g. http://techo-ecco.com/blog/xstream-spring-ws-oxm-and-generics/


I would suggest to overcome the issues with interfaces and generics you have with JAXB.

JAXB Marshalling and Generics

java.util.List is an interface, and JAXB can't handle interfaces

0

精彩评论

暂无评论...
验证码 换一张
取 消