JAXB xjcツールを使用して、複数の xsd ファイルから Java クラスを生成しました (オンライン ツールを使用して、xml ファイルから xsd ファイルを生成しました)。
私の問題は、context.xml を構成して、指定されたすべてのクラス (および xml) を読み取り、最終的な大きな xml ファイルを 1 つだけ生成する方法がわからないことです。
ここに私のcontext.xmlがあります:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<import resource="../config/context.xml" />
<batch:job id="bghJob" parent="simpleJob">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="multiResourceReader" writer="xmlItemWriter"
commit-interval="1" />
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="multiResourceReader"
class=" org.springframework.batch.item.file.MultiResourceItemReader">
<property name="resources" value="classpath:xml/*.xml" />
<property name="delegate" ref="xmlItemReader" />
</bean>
<bean id="xmlItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="unmarshaller" ref="invoiceUnMarshaller" />
<property name="fragmentRootElementName" value="DocumentType" />
</bean>
<bean id="invoiceUnMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<value>com.xxx.generatedByJaxb.inv.DocumentType</value>
</property>
</bean>
<bean id="xmlItemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="resource" value="file:xml/outputs/Facture.xml" />
<property name="marshaller" ref="invoiceMarshaller" />
<property name="rootTagName" value="Facture" />
</bean>
<bean id="invoiceMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<value>com.xxx.generatedByJaxb.inv.DocumentType</value>
</property>
</bean>
1 つのクラス(com.xxx.generatedByJaxb.inv.DocumentType など)しか読み取れないようで、ルート タグを指定する必要がありますが、生成された Java クラスのいずれにも注釈 XmlRootElement がありません。
目標を達成するためにジョブを構成するにはどうすればよいですか?
ありがとうございました。