【问题标题】:How to change default OutputSchema.java class name generated by jsonschema2pojo in maven's POM如何在Maven的POM中更改jsonschema2pojo生成的默认OutputSchema.java类名
【发布时间】:2018-08-17 04:46:03
【问题描述】:

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

【问题讨论】:

    标签: json maven-plugin pojo jsonschema2pojo


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      注意还有一个选项叫做

      <useTitleAsClassname>true</useTitleAsClassname>
      

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-07
        • 2014-12-24
        • 2013-06-29
        • 2022-10-16
        • 2019-09-02
        • 1970-01-01
        • 1970-01-01
        • 2016-06-08
        相关资源
        最近更新 更多