import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Person { private String name; private int age; } public class Main { public static void main(String[] args) { try { JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Marshaller marshaller = jaxbContext.createMarshaller(); Person person = new Person("Alice", 25); marshaller.marshal(person, System.out); } catch (JAXBException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文