我正在尝试hbm2java
使用 maven 进行配置以生成 POJO 类和 DAO 对象。我正在处理的问题之一是未生成包名称。我为此使用以下pom:
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
</component>
</components>
<componentProperties>
<packagename>package.name</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
然而,生成的代码以以下内容开头:
// default package
// Generated 2010-05-17 13:11:51 by Hibernate Tools 3.2.2.GA
/**
* Messages generated by hbm2java
*/
public class Messages implements java.io.Serializable {
有没有办法强制 maven 生成packagename中定义的包部分?
更新:
这是我的 hibernate.cfg.xml,也是由 hibernate-tools (hbm2cfgxml) 自动生成的:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/db</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<mapping resource="package/name/Messages.hbm.xml" />
</session-factory>
</hibernate-configuration>