如何在maven的POM中更改jsonschema2pojo生成的默认OutputSchema.java类名

时间:2018-03-08 18:09:26

标签: json maven-plugin pojo jsonschema2pojo

在在线工具http://www.jsonschema2pojo.org/中,有一个选项可以设置类名,因此生成的根类将按照我的意愿命名。 我无法在maven-plugin选项中找到相同的选项,生成的根类具有默认名称:OutputSchema.java 有没有办法设置它? 我的pom.xml

            <plugin>
            <groupId>org.jsonschema2pojo</groupId>
            <artifactId>jsonschema2pojo-maven-plugin</artifactId>
            <version>0.5.1</version>
            <configuration>
                <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
                <outputDirectory>${basedir}/src/main/java</outputDirectory>
                <targetPackage>com.test.generated</targetPackage>
                <targetVersion>1.8</targetVersion>
                <sourceType>json</sourceType>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

2 个答案:

答案 0 :(得分:0)

好的,我自己找到了解决方案。 类名是从输入的json文件名生成的。 例如,output-schema.json将生成OutputSchema.java类

答案 1 :(得分:0)

请注意,还有一个名为

的选项
<useTitleAsClassname>true</useTitleAsClassname>

如果使用此名称,则类名称将是您在架构的title属性中指定的名称。

https://github.com/joelittlejohn/jsonschema2pojo/issues/908