I have created a spring-batch job. My reader class reads the data from the DB and gives back the dataset object having the below structure.
@XmlRootElement
@XmlType(propOrder = { "start", "end", "users"})
public class DataSet implements Serializable {
/**
* Start datetime of this data set
*/
private Date start;
/**
* End datetime of this data set
*/
private Date end;
/**
* Providers involved in this data set
*/
private List<User> users;
}
etc…… and the writer wites the above data using StaxEventItemWriter.
The resulting xml contains two root tag elements.
<root> //added by the startDocument and endDocument methods from stax writer.
<DataSet>......</DataSet> // from the dataSet xsd annotation.
</root>
i need to eliminate the with out overriding the startDocument and endDocument methods.
is there a way to do it through the configuration. its urgent please.
my writer configuartion is given below.
<bean id="testrWriter" class="com.test.writer.TestWriter"
scope="step">
<property name="testXMLWriter" ref="testXMLWriter" />
<property name="baseDirectory" value"#{jobParameters['baseDirectory']}"></property>
</bean>
<bean id="testXMLWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="overwriteOutput" value="true" />
<property name="marshaller" ref="testJaxb2Marshaller" />
</bean>
<bean id="testJaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.test.service.dto.DataSet</value>
</list>
</property>
</bean
I set the root to
!-- --finally got a valid xml.