I am trying to use the xmlStax example provided in samples.
I modified it to take the input from XML file and provide the output in a csv file,i am getting various exceptions.
i am not very clear how to set mapper objects, how to set the record values to a flat file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<import resource="applicationContext.xml"/>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
<bean id="step" class="org.springframework.batch.core.step.item.SimpleStepFactoryBean">
<property name="itemReader" ref="itemReader" />
<property name="itemWriter" ref="itemWriter" />
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="commitInterval" value="10" />
</bean>
<bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="fragmentRootElementName" value="trade" />
<property name="resource" value="file:D:/test1.xml" />
<property name="fragmentDeserializer">
<bean class="org.springframework.batch.item.xml.oxm.UnmarshallingEventReaderDeserializer">
<constructor-arg>
<bean class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="aliases" ref="aliases" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="itemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="lineAggregator" ref="lineAggregator"/>
<property name="fieldSetCreator" ref="fieldSetMapper"/>
<property name="resource" value="file:D:/test2.txt" />
</bean>
<bean id="lineAggregator" class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="names"
value="isin,quantity,price,customer" />
<property name="delimiter" value=","/>
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper"/>
<util:map id="aliases">
<entry key="trade"
value="org.springframework.batch.sample.domain.Trade" />
<entry key="isin" value="java.lang.String" />
<entry key="quantity" value="long" />
<entry key="price" value="java.math.BigDecimal" />
<entry key="customer" value="java.lang.String" />
</util:map>
<bean id="simpleJob11" class="org.springframework.batch.core.job.SimpleJob">
<property name="name" value="simpleJob11" />
<property name="restartable" value="true" />
<property name="steps">
<list>
<ref local="step"/>
</list>
</property>
<property name="jobRepository" ref="jobRepository"/>
</bean>
</beans>
Can anyone look into this and help me out, i need to do it ASAP
Thanks