我是新來的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