JAXB marshalling in Apache Camel

牧云@^-^@ 提交于 2019-12-06 15:02:43
Peter Keller

Option 1: Configure the context path

JaxbDataFormat jaxbDataFormat =  new JaxbDataFormat("foo.pojo");

OptionFactory or jaxb.index file must be defined in the given package as explained here.

Option 2: Configure the class(es) to be bound

JAXBContext jaxbContext = JAXBContext.newInstance(MyAnnotatedClass.class);
JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(jaxbContext);

I prefere Option 2.

Option 1 is recently impossible as JaxbDataFormat(String) constructor is not available as you can see in official javadoc

Documentation seems to be outdated about this point.

EDIT: BE CAREFUL there's TWO JaxbDataFormat

I have understood: there's TWO jaxbDataFormat in camel ecosystem

  • one is in camel-core package org.apache.camel.model.dataformat
  • another in camel-jaxb package org.apache.camel.converter.jaxb
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!