2011-07-04 6 views
1

初めて私がプロジェクトをビルドしたとき、私はそれが2回のやり方をやめることを止めず、今や時が来たら、私は夢中になると知っていました。私はまだ解決策を見つけられていないか、多分私はこの問題をどのように検索するか分からない。Hibernate3 Mavenプラグインの設定ミス?

ビルドプロセス内で処理されるhbm.xmlファイルがあります。まず、pom.xmlの中でそのトリックを行うべき部分を見ることができます。

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>hibernate3-maven-plugin</artifactId> 
      <version>2.2</version> 
      <executions> 
       <execution> 
        <id>generate-xml-files</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>hbm2cfgxml</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>generate-entities</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>hbm2java</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>generate-schema</id> 
        <phase>compile</phase> 
        <goals> 
         <goal>hbm2ddl</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <components> 
        <component> 
         <name>hbm2cfgxml</name> 
         <implementation>configuration</implementation> 
         <outputDirectory>target/classes</outputDirectory> 
        </component> 
        <component> 
         <name>hbm2java</name> 
         <implementation>configuration</implementation> 
         <outputDirectory>src/main/java</outputDirectory> 
        </component> 
        <component> 
         <name>hbm2ddl</name> 
         <implementation>configuration</implementation> 
         <outputDirectory>target/classes</outputDirectory> 
        </component> 
       </components> 
       <componentProperties> 
        <jdk5>true</jdk5> 
        <packagename>com.blazebit.web.cms.core.model</packagename> 
        <propertyfile>src/main/resources/database.properties</propertyfile> 
        <configurationfile>target/classes/hibernate.cfg.xml</configurationfile> 
        <!-- Tells the plugin to send the output to a file --> 
        <outputfilename>schema.sql</outputfilename> 
        <!-- Pretty Format SQL Code --> 
        <format>true</format> 
        <!-- Do not create tables automatically - other plug-ins will handle that --> 
        <export>false</export> 
        <!-- Do not print the DDL to the console --> 
        <console>false</console> 
       </componentProperties> 
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>mysql</groupId> 
        <artifactId>mysql-connector-java</artifactId> 
        <version>5.0.8</version> 
       </dependency> 
       <dependency> 
        <groupId>cglib</groupId> 
        <artifactId>cglib-nodep</artifactId> 
        <version>2.1_3</version> 
       </dependency> 
      </dependencies> 
     </plugin> 
     <plugin> 
      <groupId>com.blazebit</groupId> 
      <artifactId>HibernateCfgBuilder</artifactId> 
      <version>1.0</version> 
      <executions> 
       <execution> 
        <id>HibernateCfgBuilder</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>HibernateCfgBuilder</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <hbmXmlFilesDir>src/main/resources/com/blazebit/web/cms/core/model/</hbmXmlFilesDir> 
       <configFile>target/classes/hibernate.cfg.xml</configFile> 
       <packageName>com.blazebit.web.cms.core.model</packageName> 
      </configuration> 
     </plugin> 

ここで、このすべての操作を説明します。

  • まず最初は、私が思うhbm2cfgで、それはあるhibernate.cfg.xmlを作成する必要があります
  • 第二段階は、hibernate.cfg.xmlのにのhbm.xmlファイルへのパスを追加し、私自身のプラグイン、(あります
  • 第3のステップは、それがクラスパスに
をそのモデルのschema.sqlを作成する必要がありますhbm2ddl私のソースディレクトリ
  • そして最後にJavaファイルを生成する必要がありますどのhbm2javaです)この問題の他の解決策を見つけることができませんでした

    だからかなり簡単なunds?それはうまくいくが、何度か何度か何度かやっているようだが、私のビルドは約2分かかってしまう。/ 誰も私にこのステップを働かせるために何が変わるかを教えてもらえますか?

  • 答えて

    1

    私はそれがhibernate3-maven-pluginの目標"Invokes the execution of the lifecycle phase generate-resources prior to executing itself" as described in documentationのいくつかをいくつか挙げているので、いくつかの目標を2回呼び出すと思います。私もこの問題に直面していました。本当にお困りの場合は、maven-antrun-pluginからAntターゲットとして呼び出すことをお勧めします(ただし、これはテストしません)。

    +0

    私はこれらの手順を実行する独自のプラグインを作成することを考えています... –

    +0

    hbm2xでファイルを生成する際に大きなパフォーマンス上の問題があります。各hbm.xmlファイルが処理されるまでに約2秒かかります。私の最終的な解決策は、目標が呼び出される新しいプロファイルを作成することでした。プロファイルは手動で設定する必要があります。また、hbm2cfgを削除して、プラグインを拡張してdatabase.propertiesを解析しました。 –

    関連する問題