我正在尝试将csv文件导入xml文件
我看到apache具有功能
from(in)
.to(out)
.split(body().tokenize("\n")).streaming()
.unmarshal().csv();
但是我遇到“无法解析方法'from(java.lang.String)'错误
当我尝试导入时,我找不到骆驼的任何包裹
这是可行的:
import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
在org.apache.camel中使用“ from”的软件包是什么??
这是我的文件:
import org.apache.camel.Exchange;
import org.apache.camel.dataformat.bindy.BindyAbstractDataFormat;
import org.apache.camel.dataformat.bindy.BindyAbstractFactory;
import org.apache.camel.dataformat.bindy.BindyFixedLengthFactory;
import org.apache.camel.dataformat.bindy.FormatFactory;
import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
import org.apache.camel.dataformat.bindy.util.ConverterUtils;
import org.apache.camel.spi.DataFormat;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class Csvtoxml {
public static void convert(String in, String out) throws Exception {
DataFormat bindy = new BindyCsvDataFormat(Model.class);
from("myCsvFile.csv")
.to("myXmlFile.xml")
.split(body().tokenize("\n")).streaming()
.unmarshal().csv();
}
}
答案 0 :(得分:1)
它不是从任何地方导入的。为了以这种方式使用它,您必须从org.apache.camel.builder.RouteBuilder