【问题标题】:jsonschema2pojo maven plugin does not generate Java classesjsonschema2pojo maven 插件不生成 Java 类
【发布时间】:2019-12-07 16:37:14
【问题描述】:

我正在尝试获取FHIR R4 specification 的Java 模型。为了完成这个任务,我下载了JSON Schema并尝试使用jsonschema2pojo maven插件生成源代码。

我创建了一个简单的 Maven 项目,并将 JSON Schema 放在 src/main/resources/schema 下。所以,我定义了以下pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>fhir-generator</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9.2</version>
        </dependency>
    </dependencies>

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>1.0.1</version>
                <configuration>
                    <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
                    <targetPackage>com.example.fhir</targetPackage>
                    <useCommonsLang3>true</useCommonsLang3>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

当我运行目标 package 时,我获得以下输出:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for come.example:fhir-generator:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 24, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building fhir-generator 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- jsonschema2pojo-maven-plugin:1.0.1:generate (default) @ fhir-generator ---
[WARNING] useCommonsLang3 is deprecated. Please remove it from your config.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fhir-generator ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ fhir-generator ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fhir-generator ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ fhir-generator ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ fhir-generator ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ fhir-generator ---
[INFO] Building jar: Z:\work\backend\fhir-generator\target\fhir-generator-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.921 s
[INFO] Finished at: 2019-07-30T11:21:25+02:00
[INFO] Final Memory: 12M/208M
[INFO] ------------------------------------------------------------------------

问题是target/generated-sources 文件夹中没有生成任何类。有什么想法吗?提前通知

【问题讨论】:

  • 我不熟悉这些 jsonschema2pojo - 但是 json 模式和工具在 FHIR 所强调的一些功能方面还不成熟,所以如果你有问题我不会感到惊讶。你看过 HAPI-FHIR 吗?
  • 不是喷气机!我将看看 HAPI-FHIR。 Tnx!

标签: java maven jsonschema hl7-fhir jsonschema2pojo


【解决方案1】:

默认情况下,jsonschema2pojo 插件将文件生成到 target/java-gen/ 文件夹,而不是您指定的文件夹。

【讨论】:

    猜你喜欢
    • 2017-11-26
    • 2020-06-14
    • 2016-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    相关资源
    最近更新 更多