我正在尝试向 JAXB 从 XSD 生成的所有类添加 @javax.annotation.Generated
注释。
我正在使用 maven-jaxb2-plugin 和一个 binding.xjb 文件来生成源代码。我看到 JAXB 插件 jaxb2-basics-annotate 应该可以解决问题。但我能找到的只是为特定类添加注释的示例。就像这个:
<jaxb:bindings schemaLocation="csw/2.0.2/CSW-discovery.xsd" node="/xs:schema">
<jaxb:bindings node="xs:complexType[@name='GetRecordsType']">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="GetRecordsType" />
</annox:annotate>
</jaxb:bindings>
如何为我生成的每个文件执行此操作?这可能吗?
最佳答案
看来您正在使用 highsource/jaxb2-annotate-plugin如果你也在用他的highsource/maven-jaxb2-plugin , 内置支持此功能。只需将其添加到插件配置中:
<configuration>
<markGenerated>true</markGenerated>
</configuration>
同时检查 controlling the output .
如果你是官方的jaxb2插件,那个特性也是内置的
<configuration>
<addGeneratedAnnotation>true</addGeneratedAnnotation>
</configuration>
关于java - 将 @Generated 注释添加到 JAXB 生成的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43658839/