3

在在线工具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>
4

2 回答 2

1

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

于 2018-03-15T15:53:58.677 回答
1

请注意,还有一个名为

<useTitleAsClassname>true</useTitleAsClassname>

如果您使用它,类名将是您在架构的标题属性中指定的名称。

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

于 2020-08-20T05:29:36.427 回答