我是新来的Apache骆驼和爪哇B概念在Java中。 我有一个骆驼队列中的java对象列表。我想用Javs DSL将它Marshall到一个xml(不使用spring)。 任何人都可以指导我这样做吗?JaxB骆驼编队
我有以下POJO类
下面是JAXB实现我的骆驼代码
JaxbDataFormat jaxbMarshal = new JaxbDataFormat();
jaxbMarshal.setContextPath("com.test");
jaxbMarshal.setPartClass("com.test.MyPojo");
from("direct:javaObjects") //this direct having the list of MYPojo Objects
.marshal(jaxbMarshal)
.to("src/output");
我得到异常以下(我加了Maven的依赖在类路径JAXB)
Failed to create route route4 at: >>> Marshal[[email protected]] <<< in route: Route(route4)[[From[direct:javaObjects]] -> [Marshal[org.apa... because of Data format 'jaxb' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath
你有camel-jaxb组件在应用程序类路径中的依赖关系? –
是的,您需要将camel-jaxb添加到类路径中,并将JAXB注释添加到POJO类中,并添加'jaxb.index'文件。您可以在互联网上搜索“jaxb.index”文件。 –
谢谢@ClausIbsen。我已经注册并且工作正常 – Hari