jsonschema2pojo中的JSR-303激活 [英] JSR-303 activation in jsonschema2pojo
问题描述
jsonschema2pojo 文档中有一个地方描述了启用 JSR-303注释生成.如果我理解正确,则可以通过Maven插件配置来完成.有人可以演示如何实现它,应该在插件配置中使用哪个标签?谢谢大家!
There is a place in jsonschema2pojo documentation describing possibility to enable JSR-303 annotations generation. If I understand correctly it can be done via Maven plugin configuration. Could someone show how to accomplish it, which tag in plugin configuration should be used? Thanks to all!
推荐答案
我认为您正在寻找文档:
includeJsr303Annotations
是否包含 JSR-303批注(用于
, maximum
等).模式规则及其产生的注释:
includeJsr303Annotations
Whether to include JSR-303 annotations (for schema rules like
minimum
,maximum
, etc) in generated Java types. Schema rules and the annotation they produce:
-
maximum
=@DecimalMax
-
minimum
=@DecimalMin
-
minItems
,maxItems
= -
minLength
,maxLength
= -
pattern
=@Pattern
-
required
=@NotNull
maximum
=@DecimalMax
minimum
=@DecimalMin
minItems
,maxItems
=@Size
minLength
,maxLength
=@Size
pattern
=@Pattern
required
=@NotNull
Any Java fields which are an object or array of objects will be annotated with @Valid
to support validation of an entire document tree.
- 类型:
boolean
- 自此: 0.3.2
- 必需:否
- 表达式:
${jsonschema2pojo.includeJsr303Annotations}
- 默认值:
false
- Type:
boolean
- Since: 0.3.2
- Required: No
- Expression:
${jsonschema2pojo.includeJsr303Annotations}
- Default:
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>
这篇关于jsonschema2pojo中的JSR-303激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!