Java Spring批处理上的多xml文件
我使用Spring Batch读取数据库并写入xml文件,但我找不到一些配置来生成多xml行文件,我需要这样做:Java Spring批处理上的多xml文件,java,xml,spring,spring-batch,Java,Xml,Spring,Spring Batch,我使用Spring Batch读取数据库并写入xml文件,但我找不到一些配置来生成多xml行文件,我需要这样做: <xmlRecord><name>RecordOne</name></xmlRecord> <xmlRecord><name>RecordTwo</name></xmlRecord> <xmlRecord><name>RecordOne</name>&
<xmlRecord><name>RecordOne</name></xmlRecord>
<xmlRecord><name>RecordTwo</name></xmlRecord>
<xmlRecord><name>RecordOne</name></xmlRecord><xmlRecord><name>RecordTwo</name></xmlRecord>
RecordOne
记录二
每条记录都排成一行
但我只能这样创造:
<xmlRecord><name>RecordOne</name></xmlRecord>
<xmlRecord><name>RecordTwo</name></xmlRecord>
<xmlRecord><name>RecordOne</name></xmlRecord><xmlRecord><name>RecordTwo</name></xmlRecord>
RecordOneRecordTwo
这是我的配置:
<bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter" scope="step">
<property name="resource"
value="file:/var/opt/result.tmp" />
<property name="marshaller" ref="userUnmarshaller" />
<property name="overwriteOutput" value="true" />
<property name="RootTagName" value="!-- --"/>
</bean>
<bean id="userUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>my.jaxb.data.TCRMService</value>
</list>
</property>
<property name="marshallerProperties">
<map>
<entry>
<key><util:constant static-field="javax.xml.bind.helpers.AbstractMarshallerImpl.JAXB_SCHEMA_LOCATION"/></key>
<value>http://www.ibm.com/mdm/schema MDMDomains.xsd</value>
</entry>
</map>
</property>
</bean>
封送处理bean配置:
<bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter" scope="step">
<property name="resource"
value="file:/var/opt/result.tmp" />
<property name="marshaller" ref="userUnmarshaller" />
<property name="overwriteOutput" value="true" />
<property name="RootTagName" value="!-- --"/>
</bean>
<bean id="userUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>my.jaxb.data.TCRMService</value>
</list>
</property>
<property name="marshallerProperties">
<map>
<entry>
<key><util:constant static-field="javax.xml.bind.helpers.AbstractMarshallerImpl.JAXB_SCHEMA_LOCATION"/></key>
<value>http://www.ibm.com/mdm/schema MDMDomains.xsd</value>
</entry>
</map>
</property>
</bean>
my.jaxb.data.TCRMService
http://www.ibm.com/mdm/schema mdomains.xsd
有人可以帮助我或提供一些配置来解决我的问题?使用以下解组器配置:-
<bean id="userUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list> your_class </list>
</property>
<property name="marshallerProperties">
<map>
<entry>
<key>
<util:constant static-field="javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT" />
</key>
<value type="java.lang.Boolean">true</value>
</entry>
</map>
</property>
</bean>
你的班级
真的
您也可以这样做,如下所示:-
<property name="marshallerProperties">
<map>
<entry key="jaxb.formatted.output">
<value type="boolean">true</value>
</entry>
</map>
</property>
真的
您可以附加userMarshaller bean配置吗?@MaciejKowalski我添加了我的UserMarshall bean,可能与我尝试了您的配置相同,但得到了相同的结果