我有單獨的jar文件包含了hibernate的實體映射和直接映射。我的Hibernate confg(cgf.xml)放在另一個jar文件中。結果我發現異常「resource:com/iceleads/data/Test.hbm.xml not found」。休眠映射資源定位在單獨的jar中
例子:
entities.jar
com.package.entity.TestEntity.java
com.package.entity.TestEnity.hbm.xml
mainUsage.jar
com.package.main.MainClass.java - there are I get session factory
SessionFactory factory = HibernateUtil.getSessionFactory();
com.package.main.hibernate.cfg.xml
in HibernateUtil
sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
in hibernate.cfg.xml
<mapping resource="com/package/entity/TestEntity/Test.hbm.xml"/>
entities.jar在mainUsage.jar classpath中
請建議我我如何可以配置hibernate.cfg.xml中使用單獨的罐子實體。
非常感謝!
阿爾喬姆
你的例子不正確。 entities.jar包含一個名爲'TestEntity.hbm.xml'的文件,而hibernate.cfg.xml映射一個名爲'Test.hbm.xml'的文件......巧合? – yair 2012-11-18 22:15:49