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
精彩评论