使用 jsonschema2pojo 自动生成原始字节数组泛型
Autogenerate primitive byte array generics with jsonschema2pojo
有没有一种方法可以使用 jsonschema2pojo 从 json 自动生成 java 类,其中泛型包含原始字节数组?例如,我想生成此 private Map<String, byte[]> mappy;
,到目前为止,我设法通过使用此生成 private Map<String, Byte[]> mappy;
:
"properties": {
"mappy": {
"id": "/response/images",
"title": "(images) The images property.",
"javaType" : "java.util.Map<String, Byte[]>",
"type" : "object"
}
}
但我宁愿使用原始字节数组而不是字节数组。如果我尝试使用 byte[]
而不是 Byte[]
jsonschema2pojo 抛出异常。
好的。我想出了一个方法,在 pom.xml 文件中使用 replacer
插件,如下所示:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>Convert commons-lang to commons-lang3</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<include>${basedir}/target/java-gen/*.java</include>
</includes>
<replacements>
<replacement>
<token>Byte</token>
<value>byte</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
有没有一种方法可以使用 jsonschema2pojo 从 json 自动生成 java 类,其中泛型包含原始字节数组?例如,我想生成此 private Map<String, byte[]> mappy;
,到目前为止,我设法通过使用此生成 private Map<String, Byte[]> mappy;
:
"properties": {
"mappy": {
"id": "/response/images",
"title": "(images) The images property.",
"javaType" : "java.util.Map<String, Byte[]>",
"type" : "object"
}
}
但我宁愿使用原始字节数组而不是字节数组。如果我尝试使用 byte[]
而不是 Byte[]
jsonschema2pojo 抛出异常。
好的。我想出了一个方法,在 pom.xml 文件中使用 replacer
插件,如下所示:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>Convert commons-lang to commons-lang3</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<includes>
<include>${basedir}/target/java-gen/*.java</include>
</includes>
<replacements>
<replacement>
<token>Byte</token>
<value>byte</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>