如何使用annox插件将include=JsonSerialize.Inclusion.NON_NULL添加到@JsonSerialize
我们使用maven插件maven-jaxb2-plugin从xsd生成JAXB对象。下面是我们的依赖项 jaxb2基础知识-0.6.2如何使用annox插件将include=JsonSerialize.Inclusion.NON_NULL添加到@JsonSerialize,json,maven-jaxb2-plugin,annox,jaxb2-annotate-plugin,Json,Maven Jaxb2 Plugin,Annox,Jaxb2 Annotate Plugin,我们使用maven插件maven-jaxb2-plugin从xsd生成JAXB对象。下面是我们的依赖项 jaxb2基础知识-0.6.2 jaxb2基础注释-0.6.2 在我们的maven文件中,我们还包括了-Xannotate和-XtoString <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId&g
jaxb2基础注释-0.6.2 在我们的maven文件中,我们还包括了-Xannotate和-XtoString
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>exec1</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
<bindingDirectory>${basedir}/src/main/resources/xsd</bindingDirectory>
<generatePackage>org.learning.json.generated</generatePackage>
<generateDirectory>${basedir}/generated</generateDirectory>
<clearOutputDir>false</clearOutputDir>
<includeSchemas>
<includeSchema>Person.xsd</includeSchema>
</includeSchemas>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
</plugins>
<args>
<arg>-Xannotate</arg>
<arg>-XtoString</arg>
</args>
</configuration>
</execution>
org.jvnet.jaxb2.maven2
我也试过了
<jaxb:bindings schemaLocation="Person.xsd" multiple="true">
<jaxb:bindings node="xs:complexType[@name='personType']/xs:sequence/xs:element[@type='xs:date']" multiple="true">
<annox:annotate>
<annox:annotate target="getter" annox:class="org.codehaus.jackson.map.annotate.JsonSerialize"
using="org.learning.json.JsonDateSerializer"/>
</annox:annotate>
<annox:annotate>
@org.codehaus.jackson.map.annotate.JsonSerialize
(include=org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.ALWAYS
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>
@org.codehaus.jackson.map.annotate.json序列化
(include=org.codehaus.jackson.map.annotate.JsonSerialize.include.ALWAYS
这也没有在注释中添加任何包含部分。免责声明:我是注释的作者
首先,对于XML语法,请尝试以下方法(从开始就不推荐使用):
。我会让它工作的
注意:您必须使用或更高版本(当前版本)才能使用Java语法。您提到的XML语法非常有效。再次感谢您。
<annox:annotate>
<annox:annotate target="getter" annox:class="org.codehaus.jackson.map.annotate.JsonSerialize"
using="org.learning.json.JsonDateSerializer"
include="org.codehause.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL"/>
</annox:annotate>
<annox:annotate>
<annox:annotate target="getter" annox:class="org.codehaus.jackson.map.annotate.JsonSerialize"
using="org.learning.json.JsonDateSerializer"
include="org.codehause.jackson.map.annotate.JsonSerialize$Inclusion.NON_NULL"/>
</annox:annotate>
<jaxb:bindings schemaLocation="Person.xsd" multiple="true">
<jaxb:bindings node="xs:complexType[@name='personType']/xs:sequence/xs:element[@type='xs:date']" multiple="true">
<annox:annotate>
<annox:annotate target="getter" annox:class="org.codehaus.jackson.map.annotate.JsonSerialize"
using="org.learning.json.JsonDateSerializer"/>
</annox:annotate>
<annox:annotate>
@org.codehaus.jackson.map.annotate.JsonSerialize
(include=org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.ALWAYS
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>
<annox:annotate
target="getter"
annox:class="org.codehaus.jackson.map.annotate.JsonSerialize"
using="org.learning.json.JsonDateSerializer"
include="NON_NULL"/>
<annox:annotate>
@org.codehaus.jackson.map.annotate.JsonSerialize
(include=org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.ALWAYS)
</annox:annotate>