How to use spring to marshal and unmarshal xml?

后端 未结 4 1456
渐次进展
渐次进展 2020-12-07 23:44

I have a spring boot project. I have a few xsds in my project. I have generated the classes using maven-jaxb2-plugin. I have used this tutorial to get a sample spring boot a

4条回答
  •  醉梦人生
    2020-12-07 23:54

    If you just want serializing/deserializing bean with XML. I think jackson fasterxml is one good choice:

    ObjectMapper xmlMapper = new XmlMapper();
    String xml = xmlMapper.writeValueAsString(new Simple());  // serializing
    
    Simple value = xmlMapper.readValue("12",
         Simple.class); // deserializing
    

    maven:

    
        com.fasterxml.jackson.dataformat
        jackson-dataformat-xml
    
    

    Refer: https://github.com/FasterXML/jackson-dataformat-xml

提交回复
热议问题