hyperjaxb3不生成文件 [英] hyperjaxb3 not generating files

查看:167
本文介绍了hyperjaxb3不生成文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过学习明确指出了看看的地方:


如果您浏览target / generated-sources / xjc目录,
几个生成的java文件,例如 PurchaseOrderType.java







再一次,我不明白这一点。为我工作。



我的步骤是:


  • 解压缩 hyperjaxb3-ejb-template-basic-0.6.0-maven-src.zip 放入某个位置
  • schema.xsd 转换为 src / main / resources

  • po.xml 转换为 src / test / samples

  • mvn clean install

    这就是我得到的,很好,干净:

    pre> [INFO]扫描项目...
    [警告]
    [警告]构建org.jvnet.hyperjaxb3的有效模型时遇到了一些问题: hyperjaxb3-ejb-template-basic-maven:jar:0.6.0
    [WARNING]'build.plugins.plugin.version'for org.apache.maven.plugins:缺少maven-compiler-plugin。 @第75行,第12栏
    [警告]
    [警告]强烈建议您修复这些问题,因为它们威胁到构建的稳定性。
    [警告]
    [警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式不正确的项目。
    [警告]
    [信息]
    [信息]使用线程数为1
    的构建器org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder [ INFO]
    [信息] ----------------------------------------- -------------------------------
    [INFO]构建Hyperjaxb3示例[po-initial:maven] 0.6。 0
    [INFO] ------------------------------------------ ------------------------------
    [INFO]
    [INFO] --- maven-clean -plugin:2.5:clean(default-clean)@ hyperjaxb3-ejb-template-basic-maven ---
    [INFO]正在删除C:\Projects\workspaces\hj3\dist\hyperjaxb3- ejb-template-basic-0.6.0\target
    [INFO]
    [INFO] --- maven-hyperjaxb3-plugin:0.6.0:generate(默认)@ hyperjaxb3-ejb-template- basic-maven ---
    [信息]来源不是最新的; XJC执行将被执行。
    [WARNING]根据Java持久性API规范第2.1节,实体必须是顶级类:
    实体类必须是顶级类。
    您的JAXB模型未针对顶级本地范围设定进行自定义,请使用< jaxb:globalBinding localScoping =toplevel/>全局绑定定制。
    org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin

    [警告]根据Java持久性API规范第2.1节,实体必须实现可序列化的接口:
    If一个实体实例被作为一个分离的对象
    传递(例如,通过一个远程接口),实体类必须实现
    Serializable接口。
    您的JAXB模型未定制为可序列化,请使用< jaxb:serializable />全局绑定自定义元素,使您的模型可序列化。
    org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin

    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources(default-resources) @ hyperjaxb3-ejb-template-basic-maven ---
    [警告]使用平台编码(实际上是Cp1252)来复制已过滤的资源,即构建依赖于平台!
    [信息]复制2资源
    [信息]复制0资源
    [信息]复制1资源
    [信息]
    [信息] --- maven-compiler -plugin:2.5.1:compile(default-compile)@ hyperjaxb3-ejb-template-basic-maven ---
    [警告]文件编码尚未设置,使用平台编码Cp1252,即构建依赖于平台!
    [INFO]将5个源文件编译为C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\classes
    [ INFO]
    [INFO] --- maven-resources-plugin:2.6:testResources(default-testResources)@ hyperjaxb3-ejb-template-basic-maven ---
    [警告]使用平台编码Cp1252实际上)复制已过滤的资源,即构建依赖于平台!
    [INFO]复制2资源
    [INFO]
    [信息] --- maven-compiler-plugin:2.5.1:testCompile(default-testCompile)@ hyperjaxb3-ejb-template-基本maven ---
    [警告]文件编码尚未设置,使用平台编码Cp1252,即构建是平台相关的!
    [INFO]将5个源文件编译为C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\test-classes
    [INFO]
    [INFO] --- maven-surefire-plugin:2.12.4:test(默认测试)@ hyperjaxb3-ejb-template-basic-maven ---
    [信息] Surefire报告目录:C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\surefire-reports

    --- -------------------------------------------------- -
    测试
    --------------------------------------- ----------------
    运行RoundtripTest
    检测到[file:/ C:/ Projects / workspaces / hj3 / dist / hyperjaxb3-ejb-template-basic- 0.6.0 /目标/类/ META-INF / persistence.xml中]。
    RoundtripTest

    加载实体管理器工厂属性。
    RoundtripTest

    从[file:/ C:/Projects/workspaces/hj3/dist/hyperjaxb3-ejb-template-basic-0.6.0/target/test-类/ persistence.properties]。
    RoundtripTest

    测试样本。
    RoundtripTest

    示例目录[C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\src\test\\ \\samples。
    RoundtripTest

    测试示例[po.xml]。
    往返测试

    解组。
    RoundtripTest

    开幕式。
    RoundtripTest

    保存对象。
    RoundtripTest

    开幕式。
    RoundtripTest

    加载对象。
    RoundtripTest

    关闭会话。
    RoundtripTest

    初始对象:
    <?xml version =1.0encoding =UTF-8standalone =yes?>
    < purchaseOrder orderDate =1999-10-20>
    < shipTo country =US>
    < name> Alice Smith< / name>
    < street> 123枫叶街< / street>
    < city> Mill Valley< / city>
    < state> CA< / state>
    < zip> 90952< / zip>
    < / shipTo>
    < billTo country =US>
    < name>罗伯特史密斯< / name>
    < street> 8橡树大道< / street>
    <城市>旧城区< / city>
    < state> PA< / state>
    < zip> 95819< / zip>
    < / billTo>
    < comment>快点,我的草坪正在狂野!< / comment>
    <项目>
    < item partNum =872-AA>
    < productName>割草机< / productName>
    <数量> 1< /数量>
    < USPrice> 148.95< / USPrice>
    < comment>确认这是电动< / comment>
    < / item>
    < item partNum =926-AA>
    < productName>婴儿监护仪< / productName>
    <数量> 1< /数量>
    < USPrice> 39.98< / USPrice>
    < shipDate> 1999-05-21< / shipDate>
    < / item>
    < / item>
    < / purchaseOrder>

    RoundtripTest

    源对象:
    <?xml version =1.0encoding =UTF-8standalone =yes?>
    < purchaseOrder orderDate =1999-10-20Hjid =1>
    < shipTo country =USHjid =2>
    < name> Alice Smith< / name>
    < street> 123枫叶街< / street>
    < city> Mill Valley< / city>
    < state> CA< / state>
    < zip> 90952< / zip>
    < / shipTo>
    < billTo country =USHjid =1>
    < name>罗伯特史密斯< / name>
    < street> 8橡树大道< / street>
    <城市>旧城区< / city>
    < state> PA< / state>
    < zip> 95819< / zip>
    < / billTo>
    < comment>快点,我的草坪正在狂野!< / comment>
    <项目Hjid =1>
    < item partNum =872-AAHjid =1>
    < productName>割草机< / productName>
    <数量> 1< /数量>
    < USPrice> 148.95< / USPrice>
    < comment>确认这是电动< / comment>
    < / item>
    < item partNum =926-AAHjid =2>
    < productName>婴儿监护仪< / productName>
    <数量> 1< /数量>
    < USPrice> 39.98< / USPrice>
    < shipDate> 1999-05-21< / shipDate>
    < / item>
    < / item>
    < / purchaseOrder>

    RoundtripTest

    结果对象:
    <?xml version =1.0encoding =UTF-8standalone =yes?>
    < purchaseOrder orderDate =1999-10-20Hjid =1>
    < shipTo country =USHjid =2>
    < name> Alice Smith< / name>
    < street> 123枫叶街< / street>
    < city> Mill Valley< / city>
    < state> CA< / state>
    < zip> 90952< / zip>
    < / shipTo>
    < billTo country =USHjid =1>
    < name>罗伯特史密斯< / name>
    < street> 8橡树大道< / street>
    <城市>旧城区< / city>
    < state> PA< / state>
    < zip> 95819< / zip>
    < / billTo>
    < comment>快点,我的草坪正在狂野!< / comment>
    <项目Hjid =1>
    < item partNum =872-AAHjid =1>
    < productName>割草机< / productName>
    <数量> 1< /数量>
    < USPrice> 148.95< / USPrice>
    < comment>确认这是电动< / comment>
    < / item>
    < item partNum =926-AAHjid =2>
    < productName>婴儿监护仪< / productName>
    <数量> 1< /数量>
    < USPrice> 39.98< / USPrice>
    < shipDate> 1999-05-21< / shipDate>
    < / item>
    < / item>
    < / purchaseOrder>

    RoundtripTest

    检查文档标识。
    RoundtripTest

    完成测试示例[po.xml]。
    RoundtripTest

    完成测试样本。
    RoundtripTest

    测试运行:1,失败:0,错误:0,跳过:0,经过时间:2.456秒

    结果:

    测试运行:1,失败:0,错误:0,跳过:0

    [信息]
    [信息] --- maven-jar-plugin:2.4:jar构建jar:C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic(默认jar文件)@ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] -0.6.0\target\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar
    [INFO]
    [信息] --- maven-install-plugin:2.4:安装(default-install)@ hyperjaxb3-ejb-template-basic-maven ---
    [INFO]正在安装C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic- 0.6.0\target\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar添加到C:\ Repository\org\jvnet\hyperjaxb3\hyperjaxb3-ejb-template-basic-maven\\ \\0.6.0\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar
    [INFO]正在安装C:\Projects\worksp aces \hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\pom.xml到C:\ Repository \org\jvnet\hyperjaxb3\hyperjaxb3-ejb-template-basic- maven\0.6.0\hyperjaxb3-ejb-template-basic-maven-0.6.0.pom
    [INFO] -------------------- -------------------------------------------------- -
    [信息]建立成功
    [信息] -------------------------------- ----------------------------------------
    [信息]总时间: 11.185 s
    [信息]完成于:2014-10-09T00:56:18 + 01:00
    [信息]最终记忆:22M / 101M
    [信息] ----- -------------------------------------------------- -----------------

    我不知道为什么它不适合你。请仔细阅读 mvn clean install -X dir / b / s 日志,以便我可以检查您的设置。 p>

    I am trying to learn hyperjaxb by studying this tutorial. I followed all of the instructions down to the heading section What was Generated?. This included the following steps:

    1.) download the <a href="http://confluence.highsource.org/display/HJ3/Downloads">Basic Project Template for Hibernate and Maven</a>
    2.) unzip the file
    3.) install the xml and xsd files in the assigned locations
    4.) open up `cmd.exe`
    5.) navigate to the directory of the unzipped root folder
    6.) run mvn clean install  
    

    But nothing was generated. There is no /generated-sources/xjc directory, and there is no PurchaseOrderType.java. I did a key word search of the entire directory structure to confirm that these resources were not present after running mvn clean install. I also imported the directory structure into a new eclipse maven project and tried run as...maven clean and run as...maven build within the new eclipse maven project, but got the same lack of results.

    What can I do to get this tutorial to produce the intended generated files?

    Also, is there a better way to generate JPA entities from xsd??


    EDIT:

    As per @kapep's advice, I tried mvn generate-sources and got the following results:

    I then tried mvn clean install again, and got the following results:

    You can see the warning in the print screens that org.apache.maven.plugins:maven-compiler-plugin is missing. I found the corresponding folder in the .m2 repository on my machine and deleted it, then did a maven update project from within eclipse to re-download the library. I then did another mvn clean install, and got the same lack of results. Nothing was generated, no java file, no generated-sources directory. Nothing.

    What else can I try?


    SECOND EDIT:

    The tutorial app still DOES NOT generate the intended files, however, I was able to get rid of the warning message in the print screens by changing the maven-compiler-plugin portion of the pom to the following:

    <plugin>
        <inherited>true</inherited>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>  
    

    Note that, in addition to specifying the version, I also changed the source and target from 1.5 to 1.6, as per @Todd 's advice in this posting. I assume these refer to JDK versions. My installation uses JDK 1.6. I do not know if this is causing any problems.

    What else can I try?

    解决方案

    UPDATE

    Finally it appeared that the OP was looking for generated classes in the root directory of the project instead of target\generated-source\xjc, despite the tutorial clearly states where to look:

    If you browse the target/generated-sources/xjc directory, you'll find few generated java files, for instance PurchaseOrderType.java.


    Once again, I don't get this. Works for me.

    My steps are:

    And this is what I get, nice and clean:

    [INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for org.jvnet.hyperjaxb3:hyperjaxb3-ejb-template-basic-maven:jar:0.6.0
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 75, 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] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Hyperjaxb3 Samples [po-initial:maven] 0.6.0
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] Deleting C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target
    [INFO] 
    [INFO] --- maven-hyperjaxb3-plugin:0.6.0:generate (default) @ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] Sources are not up-to-date; XJC execution will be executed.
    [WARNING] According to the Java Persistence API specification, section 2.1, entities must be top-level classes:
    "The entity class must be a top-level class."
    Your JAXB model is not customized as with top-level local scoping, please use the <jaxb:globalBinding localScoping="toplevel"/> global bindings customization.
            org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin
    
    [WARNING] According to the Java Persistence API specification, section 2.1, entities must implement the serializable interface:
    "If an entity instance is to be passed by value as a detached object
    (e.g., through a remote interface), the entity class must implement
     the Serializable interface."
    Your JAXB model is not customized as serializable, please use the <jaxb:serializable/> global bindings customization element to make your model serializable.
            org.jvnet.hyperjaxb3.ejb.plugin.EjbPlugin
    
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hyperjaxb3-ejb-template-basic-maven ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 2 resources
    [INFO] Copying 0 resource
    [INFO] Copying 1 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hyperjaxb3-ejb-template-basic-maven ---
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 5 source files to C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\classes
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hyperjaxb3-ejb-template-basic-maven ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 2 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ hyperjaxb3-ejb-template-basic-maven ---
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 5 source files to C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\test-classes
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] Surefire report directory: C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\surefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running RoundtripTest
    Detected [file:/C:/Projects/workspaces/hj3/dist/hyperjaxb3-ejb-template-basic-0.6.0/target/classes/META-INF/persistence.xml].
        RoundtripTest
    
    Loading entity manager factory properties.
        RoundtripTest
    
    Loading entity manager factory properties from [file:/C:/Projects/workspaces/hj3/dist/hyperjaxb3-ejb-template-basic-0.6.0/target/test-classes/persistence.properties].
        RoundtripTest
    
    Testing samples.
        RoundtripTest
    
    Sample directory [C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\src\test\samples].
        RoundtripTest
    
    Testing sample [po.xml].
        RoundtripTest
    
    Unmarshalling.
        RoundtripTest
    
    Opening session.
        RoundtripTest
    
    Saving the object.
        RoundtripTest
    
    Opening session.
        RoundtripTest
    
    Loading the object.
        RoundtripTest
    
    Closing the session.
        RoundtripTest
    
    Initial object:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <purchaseOrder orderDate="1999-10-20">
        <shipTo country="US">
            <name>Alice Smith</name>
            <street>123 Maple Street</street>
            <city>Mill Valley</city>
            <state>CA</state>
            <zip>90952</zip>
        </shipTo>
        <billTo country="US">
            <name>Robert Smith</name>
            <street>8 Oak Avenue</street>
            <city>Old Town</city>
            <state>PA</state>
            <zip>95819</zip>
        </billTo>
        <comment>Hurry, my lawn is going wild!</comment>
        <items>
            <item partNum="872-AA">
                <productName>Lawnmower</productName>
                <quantity>1</quantity>
                <USPrice>148.95</USPrice>
                <comment>Confirm this is electric</comment>
            </item>
            <item partNum="926-AA">
                <productName>Baby Monitor</productName>
                <quantity>1</quantity>
                <USPrice>39.98</USPrice>
                <shipDate>1999-05-21</shipDate>
            </item>
        </items>
    </purchaseOrder>
    
        RoundtripTest
    
    Source object:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <purchaseOrder orderDate="1999-10-20" Hjid="1">
        <shipTo country="US" Hjid="2">
            <name>Alice Smith</name>
            <street>123 Maple Street</street>
            <city>Mill Valley</city>
            <state>CA</state>
            <zip>90952</zip>
        </shipTo>
        <billTo country="US" Hjid="1">
            <name>Robert Smith</name>
            <street>8 Oak Avenue</street>
            <city>Old Town</city>
            <state>PA</state>
            <zip>95819</zip>
        </billTo>
        <comment>Hurry, my lawn is going wild!</comment>
        <items Hjid="1">
            <item partNum="872-AA" Hjid="1">
                <productName>Lawnmower</productName>
                <quantity>1</quantity>
                <USPrice>148.95</USPrice>
                <comment>Confirm this is electric</comment>
            </item>
            <item partNum="926-AA" Hjid="2">
                <productName>Baby Monitor</productName>
                <quantity>1</quantity>
                <USPrice>39.98</USPrice>
                <shipDate>1999-05-21</shipDate>
            </item>
        </items>
    </purchaseOrder>
    
        RoundtripTest
    
    Result object:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <purchaseOrder orderDate="1999-10-20" Hjid="1">
        <shipTo country="US" Hjid="2">
            <name>Alice Smith</name>
            <street>123 Maple Street</street>
            <city>Mill Valley</city>
            <state>CA</state>
            <zip>90952</zip>
        </shipTo>
        <billTo country="US" Hjid="1">
            <name>Robert Smith</name>
            <street>8 Oak Avenue</street>
            <city>Old Town</city>
            <state>PA</state>
            <zip>95819</zip>
        </billTo>
        <comment>Hurry, my lawn is going wild!</comment>
        <items Hjid="1">
            <item partNum="872-AA" Hjid="1">
                <productName>Lawnmower</productName>
                <quantity>1</quantity>
                <USPrice>148.95</USPrice>
                <comment>Confirm this is electric</comment>
            </item>
            <item partNum="926-AA" Hjid="2">
                <productName>Baby Monitor</productName>
                <quantity>1</quantity>
                <USPrice>39.98</USPrice>
                <shipDate>1999-05-21</shipDate>
            </item>
        </items>
    </purchaseOrder>
    
        RoundtripTest
    
    Checking the document identity.
        RoundtripTest
    
    Finished testing sample [po.xml].
        RoundtripTest
    
    Finished testing samples.
        RoundtripTest
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.456 sec
    
    Results :
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] 
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] Building jar: C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar
    [INFO] 
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ hyperjaxb3-ejb-template-basic-maven ---
    [INFO] Installing C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\target\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar to C:\Repository\org\jvnet\hyperjaxb3\hyperjaxb3-ejb-template-basic-maven\0.6.0\hyperjaxb3-ejb-template-basic-maven-0.6.0.jar
    [INFO] Installing C:\Projects\workspaces\hj3\dist\hyperjaxb3-ejb-template-basic-0.6.0\pom.xml to C:\Repository\org\jvnet\hyperjaxb3\hyperjaxb3-ejb-template-basic-maven\0.6.0\hyperjaxb3-ejb-template-basic-maven-0.6.0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 11.185 s
    [INFO] Finished at: 2014-10-09T00:56:18+01:00
    [INFO] Final Memory: 22M/101M
    [INFO] ------------------------------------------------------------------------
    

    I have no idea why it does not work for you. Pleas post mvn clean install -X and dir /b/s logs so that I could check your setup.

    这篇关于hyperjaxb3不生成文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆