我正试图将我的ant构建迁移到maven2。在我的build.xml我调用调用:hbm2java以下列方式:如何配置hbm2java maven2插件为所有映射文件生成POJO
<hibernatetool destdir="/src/generated/">
<configuration configurationfile="${env.ITP_HOME}/core/xml/hibernate/hibernate.cfg.xml">
<fileset dir="/xml/hibernate">
<include name="*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>
我的hibernate.cfg.xml是:
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
</session-factory>
在我maven2的POM文件我有:
<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>
<configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
但是当执行mvn hibernate3:hbm2java
我看到没有文件得到生成,除非它们都列在hiberna te.cfg.xml。 有没有办法在类似于ant任务的maven配置中指定一个文件集?
感谢, NAOR
有没有人找到解决方案?我有同样的问题。我没有运行数据库,不能使用hbm2cfgxml。 – 2012-03-31 21:15:58