My Talend Job读取 XML 文件,并将它们转换为 CSV 文件。我为输入 XML 文件创建了元数据。如何从 Eclipse 运行作业,将文件名作为参数发送,然后在我的作业中接收该文件名以读取正确的 XML 文件?
1 回答
You should define XML file name as a context parameter. Later you will set it in Java code, which you will run from eclipse. In a context section(as on next image) add a new variable named "myXmlFile".
Then in your tFileInputXML in Filename/InputStream field set context.myXmlFile.
Next step is exporting the job. To do it, you should follow this instructions. Export it as "Autonomous Job".
Then in your Java project you should add to the classpath a jar generated after job exporting.
To run the job from Java code you should use the next code, in which you will define a context variable and pass it to talend job:
String args[] = new String[3];
args[0] = "--context=Default";
args[1] = "--context_param";
args[2] = "myXmlFile=/path/to/your/xml/file";
YourTallendJobClassName job = new YourTallendJobClassName ();
job.runJob(args);