2014-01-31 65 views
0

我是Maven的新手。我需要生成一個hibernate.cfg.xml,我不知道這個。在這個鏈接(http://mojohaus.org/hibernate3-maven-plugin)我不明白如何配置。有人可以幫助我嗎? 謝謝先進。如何用maven生成hibernate.cfg.xml(hibernate3-maven-plugin)?

+0

我會盡可能使用標準的'persistence.xml'而不是專有的'hibernate.cfg.xml'。 –

+0

是的。實際上,我使用build.xml來生成hibernate.cfg.xml,但是我已經使用Maven。我沒有找到任何關於此的教程來幫助我。 –

回答

0

我很抱歉拖延,但我有一個解決方案。 我有兩個存檔,是:pom.xml和build.bat(build.xml)。 build.xml具有用於生成休眠映射的配置。

我用下面的命令(類似於Gilberto Torrezan的例子)通過pom.xml運行(build.xml)。

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1</version> 
    <executions> 
    <execution> 
    <phase>generate-sources</phase> 
    <goals> 
      <goal>exec</goal> 
    </goals> 
    </execution> 
    </executions> 
    <configuration> 
    <executable>ant/build_hibernate.bat</executable> 
    </configuration> 
</plugin> 

謝謝。

0

使用plugin you mentioned,你可以在你設置這些屬性的pom.xml:

<project> 
    ... 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>hibernate3-maven-plugin</artifactId> 
     <version>3.0</version> 
     <executions> 
      <execution> 
       <goal>hbm2cfgxml</goal> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
    ... 
</project> 

該插件將在compile階段後執行。