我想用jaxb生成xml文件但是总有<?xml version="1.0" encoding="utf-8">这个文档声明,有什么方法可以去掉这个声明
public static String textMessageToXml(TextMessage textMessage) throws JAXBException{
JAXBContext jaxbContext = JAXBContext.newInstance(TextMessage.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "utf-8");
jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, false);
StringWriter writer = new StringWriter();
jaxbMarshaller.marshal(textMessage, writer);
return writer.toString();
}