【问题标题】:mvn hibernate3:hbm2ddl fails in a tutorialmvn hibernate3:hbm2ddl 在教程中失败
【发布时间】:2014-09-03 06:40:24
【问题描述】:

我正在尝试按照这本在线书籍第 7 章中的教程进行操作:http://books.sonatype.com/mvnex-book/reference/index.html

本教程旨在演示一个使用 Spring Framework 和 hibernate 的 Web 应用程序,我被困在这里:

mvn hibernate3:hbm2ddl

...
<build>
    <finalName>simple-webapp</finalName>
    <plugins>
        <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <dependencies>
                        <dependency>
                            <groupId>hsqldb</groupId>
                            <artifactId>hsqldb</artifactId>
                            <version>1.8.0.7</version>
                        </dependency>
                </dependencies>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <components>
                        <component>
                            <name>hbm2ddl</name>
                            <implementation>annotationconfiguration</implementation>
                        </component>
                    </components>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>1.8.0.7</version>
                    </dependency>
                    <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.0.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.6.7.Final</version>
            </dependency>
                </dependencies>
        </plugin>
    </plugins>
</build>

错误信息如下。任何见解或指针将不胜感激。谢谢。

@localhost simple-webapp]$ mvn hibernate3:hbm2ddl
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for     org.sonatype.mavenbook.multispring:simple-webapp:war:1.0
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is     missing. @ org.sonatype.mavenbook.multispring:simple-webapp:[unknown-version],     /home/abigail/workspace/simple-parent/simple-webapp/pom.xml, line 46, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-    plugin is missing. @ org.sonatype.mavenbook.multispring:simple-parent:1.0,     /home/abigail/workspace/simple-parent/pom.xml, line 29, 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 Simple Web Application 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) > compile @ simple-webapp     >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ simple-webapp ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e.     build is platform dependent!
[INFO] skip non existing resourceDirectory /home/abigail/workspace/simple-parent/simple-    webapp/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ simple-webapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) < compile @ simple-webapp     <<<
[INFO] 
[INFO] --- hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) @ simple-webapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.959 s
[INFO] Finished at: 2014-09-03T02:35:24-04:00
[INFO] Final Memory: 12M/208M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl     (default-cli) on project simple-webapp: There was an error creating the AntRun task.     NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the     following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

【问题讨论】:

    标签: java hibernate maven


    【解决方案1】:

    尝试为您的插件添加版本 maven-jetty-plugin 并查看是否可以解决问题,因为有一条警告说:

    [WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is     missing. @ org.sonatype.mavenbook.multispring:simple-webapp:[unknown-version],     /home/abigail/workspace/simple-parent/simple-webapp/pom.xml, line 46, column 21
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-    plugin is missing. @ org.sonatype.mavenbook.multispring:simple-parent:1.0,     /home/abigail/workspace/simple-parent/pom.xml, line 29, column 12
    

    例如:

    &lt;version&gt;4.2.14&lt;/version&gt;

    【讨论】:

      【解决方案2】:

      你可以试试下面的插件吗?

      <plugin>
          <!-- Run "mvn hibernate3:hbm2ddl" to generate schema -->
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>hibernate3-maven-plugin</artifactId>
          <version>${hibernate3.maven.plugin.version}</version>
      
          <configuration>
              <hibernatetool>
                  <annotationconfiguration propertyfile="src/main/resources/${hibernate.properties}" />
                  <hbm2ddl update="true" create="true" export="false"
                           outputfilename="${hibernate.hbm2ddl.sqlfile}" format="true"
                           console="true" />
              </hibernatetool>
          </configuration>
      </plugin>
      

      而不是

      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>hibernate3-maven-plugin</artifactId>
                      <version>2.0</version>
                      <configuration>
                          <components>
                              <component>
                                  <name>hbm2ddl</name>
                                  <implementation>annotationconfiguration</implementation>
                              </component>
                          </components>
                      </configuration>
      

      【讨论】:

        【解决方案3】:

        我遇到了和你一样的问题(使用 Java 8)并通过 将插件的版本从 2.0 切换到 2.2 解决了这个问题。如果您尝试更新的版本,它似乎又会崩溃。

        想知道是否有比反复试验和广泛使用搜索引擎更好的方法来解决此类版本问题。

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>hibernate3-maven-plugin</artifactId>
          <version>2.2</version>
          <configuration>
            <components>
              <component>
                <name>hbm2ddl</name>
                <implementation>annotationconfiguration</implementation>
              </component>
            </components>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>hsqldb</groupId>
              <artifactId>hsqldb</artifactId>
              <version>1.8.0.7</version>
            </dependency>
          </dependencies>
        </plugin>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-06-09
          • 2011-06-01
          • 2012-07-22
          • 2011-02-19
          • 2012-03-05
          • 2011-04-19
          • 2018-02-25
          相关资源
          最近更新 更多