如何配置hbm2cfgxml,以便hibernate.cfg.xml看起来像下面的(…)
我有一个使用项目
hbm2cfgxml和
<mappingresource="..."/>项目办反映路径的包名
hbm.xml。所以很明显您这边出了问题。这里有几点评论:
- 我想绑定
hbm2cfgxml
的generate-resources
阶段,你不会产生源 - 我不会在其中生成文件,
src/main/resources
但会在其中生成文件target/classses
(为什么将生成的内容放入源代码树中,所以您希望对其clean
进行清理)。 - 有一个错字
configurationfile
,不是,configurationFile
而是… - 为什么
<configurationfile>
在配置中有一个hbm2cfgxml
?您想在这里生成它…我将其删除。
更新:
您应该将连接到数据库所需的信息放在
src/main/resources/database.properties(这是
propertyfile属性的默认值)中,而不是在
src/main/resources/hibernate.cfg.xml(删除该文件)中。下面是一个样本
database.properties:
hibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriverhibernate.connection.url=jdbc:derby://localhost:1527//home/pascal/Projects/derbyDBs/EMPLDBhibernate.connection.username=APPhibernate.connection.password=APPhibernate.dialect=org.hibernate.dialect.DerbyDialect
就像我说的,删除
src/main/resources/hibernate.cfg.xml文件,您想生成它。
有没有一种方法可以告诉maven在执行hbm2java之前将资源复制到目标文件夹?(…)
的
hbm2java目标 之前,执行自身调用的生命周期阶段过程资源的执行
(从文档)。所以这是默认行为,并发生
hibernate3:hbm2java或者
generate-sources如果
hbm2java被绑定到它。



