【发布时间】:2013-10-11 13:28:26
【问题描述】:
我正在尝试对 Spring 中 Jaxb2Marshaller 类的输出 XML 进行 PrettyPrint/indent/format 处理,即使我输入了 Web 上其他地方看到的属性,该文件仍然全部位于一行中。这是我的 bean 声明:
<bean id="pingerMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
...
</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>
作者:
<bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="marshaller" ref="pingerMarshaller" />
<property name="overwriteOutput" value="true" />
<property name="resource" value="file:\C:\source\pinger\pingerExample.xml" />
</bean>
是我遗漏了什么,还是这是一个错误?
【问题讨论】:
-
这似乎是正确的。你确定 Spring 使用的是你的编组器而不是默认的吗?
-
将作者添加到问题中。看起来我正在使用正确的编组器。