gpt4 book ai didi

jaxb - jvnet maven插件jaxb类实现可序列化接口(interface)

转载 作者:行者123 更新时间:2023-12-01 00:02:36 26 4
gpt4 key购买 nike

我正在使用 maven 插件 jvnet

<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>

从 xsd 生成 jaxb 类。

我希望所有 jaxb 类都必须实现可序列化的接口(interface)。
请让我知道该怎么做。

最佳答案

只需创建一个 global.xjb 文件在你的 bindingDirectory

捆绑

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:annox="http://annox.dev.java.net"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<jaxb:globalBindings>
<xjc:serializable uid="-1"/>
</jaxb:globalBindings>
</jaxb:bindings>

示例插件配置

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<bindingDirectory>src/main/resources/xsd</bindingDirectory>
</configuration>
</plugin>

关于jaxb - jvnet maven插件jaxb类实现可序列化接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32137596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com