2

XML-JavaデータバインディングにJiBXを使用しています。現在の構成ではクラスがかなりうまく生成されますが、これらの生成されたクラスにjava.io.Serializableを実装してもらいたいです。

これは、指定されたスキーマからJavaクラスを生成するためのMavenプラグインの構成です。

<plugin>
    <groupId>org.jibx</groupId>
    <artifactId>jibx-maven-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <schemaLocation>src/main/resources</schemaLocation>            
        <includeSchemas>
            <includeSchema>FS_OTA_VehResRS.xsd</includeSchema>
        </includeSchemas>
        <options>
            <package>com.test.cars.model.ota2009a.vehresrs</package>
        </options>
        <schemaBindingDirectory>src/main/java</schemaBindingDirectory>
        <includeSchemaBindings>
            <includeSchemaBinding>*_binding.xml</includeSchemaBinding>
        </includeSchemaBindings>
    </configuration>
    <executions>            
        <execution>
        <id>generate-java-code-from-schema</id>
        <goals>
            <goal>schema-codegen</goal>
        </goals>
        </execution>
        <execution>
        <id>compile-the-binding-</id>
        <goals>
            <goal>bind</goal>
        </goals>
        </execution>            
    </executions>
</plugin>

このリンクorg.jibx.schema.codegen.extend.SerializableDecoratorは、生成されたすべてのクラスにjava.io.Serializableを実装するために使用することを提案しています。しかし、カスタマイズファイルを作成してjibx-maven-pluginを構成する方法がわかりません。

誰かがこれを達成するために私を導いてくれますか?

4

1 に答える 1

3

私はそれを得ることができます。

src / main / resources/schema-customizations.xmlを作成しました。このカスタム構成ファイルの内容は次のとおりです。

<schema-set xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <class-decorator class="org.jibx.schema.codegen.extend.SerializableDecorator"/>
</schema-set>

また、pom.xmlを変更して、カスタマイズ構成を追加しました。<configuration>

<customizations>
    <customization>src/main/resources/schema-customizations.xml</customization>
</customizations>

実行しますmvn jibx:schema-codegen

これで、生成されたすべてのクラスが実装されますjava.io.Serializable

ありがとう@SB

于 2011-10-04T13:26:47.377 に答える