2

jsonschema2pojo文档中有一个地方描述了启用JSR-303 注释生成的可能性。如果我理解正确,它可以通过 Maven 插件配置来完成。有人可以展示如何完成它,应该使用插件配置中的哪个标签?谢谢大家!

4

2 回答 2

5

我认为您正在寻找includeJsr303Annotations参数。请参阅插件文档

包括Jsr303注解

是否在生成的 Java 类型中包含JSR-303 注释minimum(用于、等模式规则)。maximum模式规则和它们产生的注释:

任何作为对象或对象数组的 Java 字段都将被注释@Valid以支持对整个文档树的验证。

  • 类型: boolean
  • 自: 0.3.2
  • 要求:
  • 表达: ${jsonschema2pojo.includeJsr303Annotations}
  • 默认: false

它可以如下使用:

<plugins>
    <plugin>
        <groupId>org.jsonschema2pojo</groupId>
        <artifactId>jsonschema2pojo-maven-plugin</artifactId>
        <version>0.4.27</version>
        <configuration>
            <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
            <targetPackage>com.example.types</targetPackage>
            <includeJsr303Annotations>true</includeJsr303Annotations>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
于 2016-10-05T14:01:24.903 回答
2

我找到了描述 Maven 插件配置标签的地方,“includeJsr303Annotations”应该用于我的情况。

于 2016-10-05T13:56:23.457 回答