updated header to csv
This commit is contained in:
parent
09bc7399dd
commit
b7bbd20155
|
@ -27,7 +27,7 @@ public class App {
|
|||
try {
|
||||
JobExecution execution = jobLauncher.run(job, new JobParameters());
|
||||
System.out.println("Job Status : " + execution.getStatus());
|
||||
System.out.println("Job completed");
|
||||
System.out.println("Job succeeded");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Job failed");
|
||||
|
|
|
@ -50,6 +50,7 @@ public class SpringBatchConfig {
|
|||
DefaultLineMapper<Transaction> lineMapper = new DefaultLineMapper<Transaction>();
|
||||
lineMapper.setLineTokenizer(tokenizer);
|
||||
lineMapper.setFieldSetMapper(new RecordFieldSetMapper());
|
||||
reader.setLinesToSkip(1);
|
||||
reader.setLineMapper(lineMapper);
|
||||
return reader;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
username, user_id, transaction_date, transaction_amount
|
||||
devendra, 1234, 31/10/2015, 10000
|
||||
john, 2134, 3/12/2015, 12321
|
||||
robin, 2134, 2/02/2015, 23411
|
|
|
@ -1,18 +1,15 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/batch
|
||||
http://www.springframework.org/schema/batch/spring-batch-3.0.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||
">
|
||||
http://www.springframework.org/schema/batch/spring-batch-3.0.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||
">
|
||||
|
||||
<import resource="spring.xml" />
|
||||
|
||||
<bean id="itemReader"
|
||||
class="org.springframework.batch.item.file.FlatFileItemReader">
|
||||
|
||||
<bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
|
||||
<property name="resource" value="input/record.csv" />
|
||||
|
||||
<property name="lineMapper">
|
||||
<bean
|
||||
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
|
||||
|
@ -20,23 +17,21 @@
|
|||
<bean
|
||||
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
|
||||
<property name="names"
|
||||
value="username,userid,transactiondate,amount" />
|
||||
value="username,userid,transaction_date,transaction_amount" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="fieldSetMapper">
|
||||
<bean
|
||||
class="org.baeldung.spring_batch_intro.service.RecordFieldSetMapper" />
|
||||
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="linesToSkip" value="1" />
|
||||
</bean>
|
||||
|
||||
<bean id="itemProcessor"
|
||||
class="org.baeldung.spring_batch_intro.service.CustomItemProcessor" />
|
||||
<bean id="itemProcessor" class="org.baeldung.spring_batch_intro.service.CustomItemProcessor" />
|
||||
|
||||
<bean id="itemWriter"
|
||||
class="org.springframework.batch.item.xml.StaxEventItemWriter">
|
||||
<bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter">
|
||||
<property name="resource" value="file:xml/output.xml" />
|
||||
<property name="marshaller" ref="recordMarshaller" />
|
||||
<property name="rootTagName" value="transactionRecord" />
|
||||
|
@ -45,13 +40,11 @@
|
|||
<bean id="recordMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="classesToBeBound">
|
||||
<list>
|
||||
<value>org.baeldung.spring_batch_intro.model.Transaction
|
||||
</value>
|
||||
<value>org.baeldung.spring_batch_intro.model.Transaction</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<batch:job id="firstBatchJob">
|
||||
<batch:step id="step1">
|
||||
<batch:tasklet>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><transactionRecord><transactionRecord><amount>10000.0</amount><transactionDate>2015-10-31T00:00:00+08:00</transactionDate><userId>1234</userId><username>devendra</username></transactionRecord><transactionRecord><amount>12321.0</amount><transactionDate>2015-12-03T00:00:00+08:00</transactionDate><userId>2134</userId><username>john</username></transactionRecord><transactionRecord><amount>23411.0</amount><transactionDate>2015-02-02T00:00:00+08:00</transactionDate><userId>2134</userId><username>robin</username></transactionRecord></transactionRecord>
|
||||
<?xml version="1.0" encoding="UTF-8"?><transactionRecord><transactionRecord><amount>10000.0</amount><transactionDate>2015-10-31T00:00:00+05:30</transactionDate><userId>1234</userId><username>devendra</username></transactionRecord><transactionRecord><amount>12321.0</amount><transactionDate>2015-12-03T00:00:00+05:30</transactionDate><userId>2134</userId><username>john</username></transactionRecord><transactionRecord><amount>23411.0</amount><transactionDate>2015-02-02T00:00:00+05:30</transactionDate><userId>2134</userId><username>robin</username></transactionRecord></transactionRecord>
|
Loading…
Reference in New Issue