在jsonschema2pojo文档中有一个地方描述了启用JSR-303注释生成的可能性。如果我正确理解,它可以通过Maven插件配置来完成。有人能告诉我们如何完成它吗?在插件配置中应该使用哪个标签?感谢大家!
发布于 2016-10-05 14:01:24
我认为您正在寻找includeJsr303Annotations参数。参见插件文档
includeJsr303Annotations 是否在生成的Java类型中包括JSR-303注解 (用于
minimum、maximum等模式规则)。模式规则及其产生的注释:
maximum = @DecimalMaxminimum = @DecimalMinminItems,maxItems = @SizeminLength,maxLength = @Sizepattern = @Patternrequired = @NotNull任何作为对象或对象数组的Java字段都将使用@Valid进行注释,以支持对整个文档树的验证。
boolean${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-05 13:56:23
我发现这里的地点插件配置标签是描述的,"includeJsr303Annotations“应该在我的例子中使用。
https://stackoverflow.com/questions/39875725
复制相似问题