【问题标题】:Executing ddl-generation while install phase在安装阶段执行 ddl-generation
【发布时间】:2013-12-11 21:07:59
【问题描述】:

我找到了ddl-generation 的此页面,我当前的代码如下所示:

        <plugin>
            <!-- run "mvn clean install -Dmaven.test.skip=true -X hibernate3:hbm2ddl" to generate a schema -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <components>
                    <component>
                        <name>hbm2ddl</name>
                        <implementation>jpaconfiguration</implementation>
                    </component>
                </components>
                <componentProperties>
                    <persistenceunit>Default</persistenceunit>
                    <outputfilename>schema.ddl</outputfilename>
                    <drop>false</drop>
                    <create>true</create>
                    <export>false</export>
                    <format>true</format>
                </componentProperties>
            </configuration>
        </plugin>

使用命令“mvn clean install -Dmaven.test.skip=true -X hibernate3:hbm2ddl”可以正常工作,但 ddl 不会由“mvn clean install”生成。 我该如何更改?

谢谢!

【问题讨论】:

    标签: java hibernate maven plugins ddl


    【解决方案1】:

    您需要将hbm2ddl 目标中的bind the execution 转换为maven lifecycle phase。您可以绑定到install 阶段,但在生成 ddl 的情况下,我建议您使用generate-sources 阶段(如果需要,这将允许您在安装之前将生成的 ddl 打包到内置工件中)。

    比如加个赞

    <executions>
      <execution>
          <id>execute-hbm2ddl</id>
          <phase>generate-sources</phase>
          <goals>
              <goal>hbm2ddl</goal>
          </goals>
          ... <!-- configuration here -->
      </execution>
    </executions>
    

    得到

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
              <execution>
                <id>execute-hbm2ddl</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>hbm2ddl</goal>
                </goals>
                <configuration>
                    <components>
                        <component>
                            <name>hbm2ddl</name>
                            <implementation>jpaconfiguration</implementation>
                        </component>
                    </components>
                    <componentProperties>
                        <persistenceunit>Default</persistenceunit>
                        <outputfilename>schema.ddl</outputfilename>
                        <drop>false</drop>
                        <create>true</create>
                        <export>false</export>
                        <format>true</format>
                    </componentProperties>
                </configuration>
              </execution>
            </executions>
        </plugin>
    

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2014-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      相关资源
      最近更新 更多