大佬教程收集整理的这篇文章主要介绍了我可以用代码替换jaxb.properties吗?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以执行以下操作以获取JAXBContext
没有jaxb.propertIEs
文件的Eclipselink JAXB(MOXy):
import java.io.file;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
public class Demo {
public static voID main(String[] args) throws Exception {
//JAXBContext jc = JAXBContext.newInstance(Animals.class);
JAXBContext jc = JAXBContextFactory.createContext(new Class[] {Animals.class}, null);
Unmarshaller unmarshaller = jc.createUnmarshaller();
file xml = new file("src/forum6871469/input.xml");
Animals animals = (Animals) unmarshaller.unmarshal(xml);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, truE);
marshaller.marshal(animals, System.out);
}
}
以上是大佬教程为你收集整理的我可以用代码替换jaxb.properties吗?全部内容,希望文章能够帮你解决我可以用代码替换jaxb.properties吗?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。