使数据模型类可序列化
我正在使用 JiBX 进行 XML-Java 数据绑定。当前配置生成的类非常好,但我希望这些生成的类实现 java.io.Serializable。
这是 Maven 插件配置,用于从给定模式生成 java 类。
<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 .SerializedDecorator
以便为所有生成的类实现 java.io.Serializable。但我不知道如何编写自定义文件和配置 jibx-maven-plugin。
谁能指导我实现这一目标?
I am using JiBX for XML-Java data binding. The current configuration generates classes pretty well but I want these generated classes to implement java.io.Serializable.
Here is maven plugin configuration to generate java classes from given schema.
<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>
This link suggesting to use org.jibx.schema.codegen.extend.SerializableDecorator
in order implement java.io.Serializable to all generated classes. But I don't have idea how to write customization file and configure jibx-maven-plugin.
Can anyone please guide me to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够得到它。
我创建了 src/main/resources/schema-customizations.xml。这个自定义配置文件的内容是:
还修改了 pom.xml 以在
下添加自定义配置并运行
mvn jibx:schema-codegen
现在所有生成的类正在实现 java.io.Serialized
谢谢@SB
I am able to get it.
I created src/main/resources/schema-customizations.xml. The content of this custom config file is:
Also modified pom.xml to add in customization configuration under
<configuration>
and run
mvn jibx:schema-codegen
Now all generated classes are implementing
java.io.Serializable
Thanks @SB