首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jsonix-模式-编译器Maven用法

jsonix-模式-编译器Maven用法
EN

Stack Overflow用户
提问于 2016-04-19 16:57:19
回答 1查看 635关注 0票数 0

根据jsonix-schema-compiler,我试过使用https://github.com/highsource/jsonix-schema-compiler/wiki/Maven-Usage,但它不起作用

我甚至尝试说明以下的其他论据:

代码语言:javascript
复制
<build>
   <finalName>test-json</finalName>
   <plugins>
     <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.13.1</version>

        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <extension>true</extension>
                    <args>
                        <arg>-Xjsonix</arg>
                        <arg>-generateJsonSchema</arg>                          
                        <arg>-d</arg>
                        <arg>${basedir}/target/generated-sources/</arg>                         
                        <arg>-b</arg>
                        <arg>${basedir}/src/main/resources/xsd/jaxb_bindings.xjb</arg>                  
                        <arg>-p</arg>
                        <arg>CustomerJSON</arg>
                        <arg>-Xjsonix-logLevel</arg>
                        <arg>TRACE</arg>
                        <arg>${basedir}/src/main/resources/xsd/Customer.xsd</arg>
                    </args>
                    <plugins>
                        <plugin>
                            <groupId>org.hisrc.jsonix</groupId>
                            <artifactId>jsonix-schema-compiler</artifactId>
                            <version>${jsonix-schema-compiler.version}</version>
                        </plugin>
                    </plugins>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

但是没有什么改变,我得到的只是警告没有模式要编译。跳过XJC执行。如下面的日志所示

代码语言:javascript
复制
    C:\test-json>mvn clean install  -Dmaven.test.skip=true
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Module test-json 1.0.0.0
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test-json ---
    [INFO] Deleting C:\test-json\target
    [INFO]
    [INFO] --- build-helper-maven-plugin:1.9:maven-version (maven-version) @ test-json ---
    [INFO]
    [INFO] --- build-helper-maven-plugin:1.9:parse-version (parse-project-version) @ test-json ---
    [INFO]
    [INFO] --- build-helper-maven-plugin:1.9:timestamp-property (extract-build-year) @ test-json ---
    [INFO]
    [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-cub3-rules) @ test-json ---
    [INFO]
    [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-cub3-warnings) @ test-json ---
    [WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
    Property 'cub-distrib-mirror-url' should be defined in your settings.
    [INFO]
    [INFO] --- jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (pre-unit-test) @ test-json ---
    [INFO] argLine set to -javaagent:C:\\Users\\...\\jacoco-ut.exec,append=true
    [INFO]
    [INFO] --- maven-jaxb2-plugin:0.13.1:generate (default) @ test-json ---
    [WARNING] No schemas to compile. Skipping XJC execution.
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test-json ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 4 resources
    [INFO] skip non existing resourceDirectory C:\test-json\target\generated-sources\xjc
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test-json ---
    [INFO] No sources to compile
    [INFO]
    [INFO] --- findbugs-maven-plugin:2.5.4:findbugs (findbugs) @ test-json ---
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ test-json ---
    [INFO] Not copying test resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ test-json ---
    [INFO] Not compiling test sources
    [INFO]
    [INFO] --- maven-surefire-plugin:2.17:test (default-test) @ test-json ---
    [INFO] Tests are skipped.
    [INFO]
    [INFO] --- jacoco-maven-plugin:0.7.4.201502262128:report (post-unit-test) @ test-json ---
    [INFO] Skipping JaCoCo execution due to missing execution data file:C:\test-json\target\coverage-reports\jacoco-ut.exec
    [INFO]
    [INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ test-json ---
    [INFO] Building jar: C:\test-json\target\test-json.jar
    [INFO]
    [INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ test-json ---
    [INFO]
    [INFO] --- jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (pre-integration-test) @ test-json ---
    [INFO] argLine set to -javaagent:C:\\Users\\...\\jacoco-it.exec,append=true
    [INFO]
    [INFO] >>> maven-pmd-plugin:3.2:check (default) > :pmd @ test-json >>>
    [INFO]
    [INFO] --- maven-pmd-plugin:3.2:pmd (pmd) @ test-json ---
    [INFO]
    [INFO] <<< maven-pmd-plugin:3.2:check (default) < :pmd @ test-json <<<
    [INFO]
    [INFO] --- maven-pmd-plugin:3.2:check (default) @ test-json ---
    [INFO]
    [INFO] >>> maven-pmd-plugin:3.2:cpd-check (check-duplication) > :cpd @ test-json >>>
    [INFO]
    [INFO] --- maven-pmd-plugin:3.2:cpd (cpd) @ test-json ---
    [INFO]
    [INFO] <<< maven-pmd-plugin:3.2:cpd-check (check-duplication) < :cpd @ test-json <<<
    [INFO]
    [INFO] --- maven-pmd-plugin:3.2:cpd-check (check-duplication) @ test-json ---
    [INFO]
    [INFO]
    [INFO] >>> findbugs-maven-plugin:2.5.4:check (findbugs) > :findbugs @ test-json >>>
    [INFO]
    [INFO] --- findbugs-maven-plugin:2.5.4:findbugs (findbugs) @ test-json ---
    [INFO]
    [INFO] <<< findbugs-maven-plugin:2.5.4:check (findbugs) < :findbugs @ test-json <<<
    [INFO]
    [INFO] --- findbugs-maven-plugin:2.5.4:check (findbugs) @ test-json ---
    [INFO]
    [INFO] --- maven-checkstyle-plugin:2.12.1:check (default) @ test-json ---
    [INFO]
    [INFO] --- jacoco-maven-plugin:0.7.4.201502262128:report (post-integration-test) @ test-json ---
    [INFO] Skipping JaCoCo execution due to missing execution data file:C:\test-json\target\coverage-reports\jacoco-it.exec
    [INFO]
    [INFO] --- maven-install-plugin:2.5.1:install (default-install) @ test-json ---
    [INFO] Installing C:\test-json\target\test-json.jar to C:\Users\...\test-json\1.0.0.0\test-json-1.0.0.0.jar
    [INFO] Installing C:\test-json\pom.xml to C:\Users\..\test-json\1.0.0.0\test-json-1.0.0.0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 5.931 s
    [INFO] Finished at: 2016-04-19T18:16:09+02:00
    [INFO] Final Memory: 38M/444M
    [INFO] ------------------------------------------------------------------------
    C:\test-json>

那么,jsonix模式编译器的好配置是什么呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-22 08:12:56

您不应该在Maven配置中“镜像”命令行XJC/的使用。它更适用于约定而不是配置。

因此,只需将模式和绑定文件放在src/main/resources中,然后打开带有-Xjsonix的Jsonix插件即可。

代码语言:javascript
复制
<build>
   <finalName>test-json</finalName>
   <plugins>
     <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.13.1</version>

        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <extension>true</extension>
                    <args>
                        <arg>-Xjsonix</arg>
                        <arg>-Xjsonix-generateJsonSchema</arg>                          
                    </args>
                    <plugins>
                        <plugin>
                            <groupId>org.hisrc.jsonix</groupId>
                            <artifactId>jsonix-schema-compiler</artifactId>
                            <version>${jsonix-schema-compiler.version}</version>
                        </plugin>
                    </plugins>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

如果您实际上想重新配置源目录和目标目录等等,请检查maven-jaxb2-plugin 结合体 (例如,请参见备忘单 )。具体来说,对于您可能需要的配置:

  • schemaDirectory
  • bindingDirectory
  • generatePackage -不建议使用,请在绑定文件中指定包和模块名,请参阅
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36724802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档