|
| 1 | +<beans xmlns="http://www.springframework.org/schema/beans" |
| 2 | + xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 3 | + xsi:schemaLocation="http://www.springframework.org/schema/batch |
| 4 | + http://www.springframework.org/schema/batch/spring-batch-3.0.xsd |
| 5 | + http://www.springframework.org/schema/beans |
| 6 | + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
| 7 | + "> |
| 8 | + |
| 9 | + <import resource="spring.xml" /> |
| 10 | + |
| 11 | + <bean id="record" class="org.baeldung.spring_batch_intro.model.Transaction"></bean> |
| 12 | + |
| 13 | + <bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader"> |
| 14 | + |
| 15 | + <property name="resource" value="input/record.csv" /> |
| 16 | + |
| 17 | + <property name="lineMapper"> |
| 18 | + <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> |
| 19 | + <property name="lineTokenizer"> |
| 20 | + <bean |
| 21 | + class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"> |
| 22 | + <property name="names" value="username,userid,transactiondate,amount" /> |
| 23 | + </bean> |
| 24 | + </property> |
| 25 | + <property name="fieldSetMapper"> |
| 26 | + <bean |
| 27 | + class="org.baeldung.spring_batch_intro.service.RecordFieldSetMapper" /> |
| 28 | + |
| 29 | + </property> |
| 30 | + </bean> |
| 31 | + </property> |
| 32 | + </bean> |
| 33 | + |
| 34 | + <bean id="itemProcessor" |
| 35 | + class="org.baeldung.spring_batch_intro.service.CustomItemProcessor" /> |
| 36 | + |
| 37 | + <bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter"> |
| 38 | + <property name="resource" value="file:xml/output.xml" /> |
| 39 | + <property name="marshaller" ref="recordMarshaller" /> |
| 40 | + <property name="rootTagName" value="transactionRecord" /> |
| 41 | + </bean> |
| 42 | + |
| 43 | + <bean id="recordMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> |
| 44 | + <property name="classesToBeBound"> |
| 45 | + <list> |
| 46 | + <value>org.baeldung.spring_batch_intro.model.Transaction</value> |
| 47 | + </list> |
| 48 | + </property> |
| 49 | + </bean> |
| 50 | + |
| 51 | + |
| 52 | + <batch:job id="firstBatchJob"> |
| 53 | + <batch:step id="step1"> |
| 54 | + <batch:tasklet> |
| 55 | + <batch:chunk reader="itemReader" writer="itemWriter" |
| 56 | + processor="itemProcessor" commit-interval="10"> |
| 57 | + </batch:chunk> |
| 58 | + </batch:tasklet> |
| 59 | + </batch:step> |
| 60 | + </batch:job> |
| 61 | +</beans> |
0 commit comments