我如何在 spring 批次 xml 中更改标签名称
How i can change tag name in spring batch xml
我有一个 spring 批处理项目来创建 xml 文件,return 这个:
<UNITS>
<pojo.unitgen>
<event>Z_RECEIVING_RESULT</event>
<type>Receipt</type>
<internalDeviceId>6</internalDeviceId>
<imei>990000223446789</imei>
</pojo.unitgen>
<pojo.unitgen>
<event>Z_RECEIVING_RESULT</event>
<type>Receipt</type>
<internalDeviceId>2</internalDeviceId>
<imei>992000123456789</imei>
</pojo.unitgen>
</UNITS>
我如何为 'unit'
更改标签 'pojo.unitgen'
这是我的 ItemWriter:
<!-- write extracted Receiving data into a xml file -->
<bean id="iwReceiving" class="org.springframework.batch.item.xml.StaxEventItemWriter"
scope="step">
<property name="resource" value="file:${Report.pathToSave}${Report.fileName}" />
<property name="marshaller" ref="UnitMarshaller" />
<property name="rootTagName" value="UNITS" />
</bean>
<bean id="UnitMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true"/>
</bean>
我假设,你有一个 class "UnitGen" 包 "pojo",对吧?
尝试使用注释“@XStreamAlias”:
package pojo;
@XStreamAlias("unit")
public class UnitGen {
...
}
您可能必须设置带注释的 classes:
<bean id="UnitMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true"/>
<property name="annotatedClasses">
<list>
<value>pojo.UnitGen</value>
</list>
</property>
</bean>
我有一个 spring 批处理项目来创建 xml 文件,return 这个:
<UNITS>
<pojo.unitgen>
<event>Z_RECEIVING_RESULT</event>
<type>Receipt</type>
<internalDeviceId>6</internalDeviceId>
<imei>990000223446789</imei>
</pojo.unitgen>
<pojo.unitgen>
<event>Z_RECEIVING_RESULT</event>
<type>Receipt</type>
<internalDeviceId>2</internalDeviceId>
<imei>992000123456789</imei>
</pojo.unitgen>
</UNITS>
我如何为 'unit'
更改标签 'pojo.unitgen'这是我的 ItemWriter:
<!-- write extracted Receiving data into a xml file -->
<bean id="iwReceiving" class="org.springframework.batch.item.xml.StaxEventItemWriter"
scope="step">
<property name="resource" value="file:${Report.pathToSave}${Report.fileName}" />
<property name="marshaller" ref="UnitMarshaller" />
<property name="rootTagName" value="UNITS" />
</bean>
<bean id="UnitMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true"/>
</bean>
我假设,你有一个 class "UnitGen" 包 "pojo",对吧? 尝试使用注释“@XStreamAlias”:
package pojo;
@XStreamAlias("unit")
public class UnitGen {
...
}
您可能必须设置带注释的 classes:
<bean id="UnitMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true"/>
<property name="annotatedClasses">
<list>
<value>pojo.UnitGen</value>
</list>
</property>
</bean>