我想用maven生成我的类和hibernate.cfg.xml。 嗯,我有我的项目中的类取决于生成的Java文件,所以我可能要执行这个过程项目清理或如此?我不知道如何配置这个工作,所以这是一个问题。 那么我有一个database.properties文件是好的,我修改了很多hbm.xml文件。现在我想从hbm.xml文件和database.properties文件中生成hibernate.cfg.xml和所有java文件。 我目前的Maven项看起来是这样的:Maven与休眠工具
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<propertyfile>src/main/resources/database.properties</propertyfile>
</componentProperties>
</configuration>
</execution>
</executions>
<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>
谁能帮助我?我真的不知道该怎么做,才能让这件事情起作用。
'generate-sources'似乎是一个apt'phase'来运行这个。如果有的话,你得到的错误是什么?另外,如果要在每次构建期间重新生成源代码,则不希望将生成的源代码放在“src/main/java”中。 – Raghuram 2011-05-30 08:57:38
我通过编写我自己的maven插件解决了我的问题,该插件负责在配置文件中添加xml映射元素。如果有人对这个插件感兴趣,请给我一个下午左右的时间。 – 2011-05-30 13:34:43