我想打印到控制檯與Apache駱駝格式化XML文件:XML文件標準:出(格式化)與Apache駱駝
預期成果是:
XML - >
<client book="Camel in Action" author="4995" title="1"/>
STD:出 - >
Client
book: Camel in Action
author: 4995
title: 1
我當前的代碼:
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
JAXBContext jaxbContext =
JAXBContext.newInstance(Client.class);
JaxbDataFormat jaxbDataFormat = new
JaxbDataFormat(jaxbContext);
from("file:/home/tkaczmarek/usr/data/inbox/")
.unmarshal(jaxbDataFormat)
.to("file:/home/tkaczmarek/usr/data/outbox")
.log("${body}");
}
}
Client.java
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Client {
@XmlAttribute
private String book;
@XmlAttribute
private String author;
@XmlAttribute
private String title;
}
如何,我可以得到預期的輸出?現在它只是打印到標準:只是xml文件與標籤:(
如果刪除解組(jaxbDataFormat)? – ltsallas
不工作,與以前相同的輸出刪除 – Tomasz
在解組和之間放置.to(「log ...」)?(「file ...」)? – user3206236