Reputation: 1003
I have my xml : launch-context.xml contains :
<bean id="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="resource" value="file:#{jobParameters['input.file.name']}" />
<property name="lineMapper" ref="lineMapper"/>
</bean>
I want to save arg[0] as the filePath. Is this the correct way? I am not sure
public static void main(String[] args) {
JobParameters param = new JobParametersBuilder().addString("input.file.name", args[0]).toJobParameters();
ApplicationContext context = new ClassPathXmlApplicationContext("launch-context.xml");
}
Thanks
Upvotes: 1
Views: 1679
Reputation: 994
All you have to do is point filePath
to args[0]
. You should put a setter method in your Config class:
public static void setFilePath(String path) {
this.filePath = path;
}
and add to your main method (assuming the name of your other class is Config
):
Config.setFilePath(args[0]);
Upvotes: 1