我需要提供一個jar文件,它提供了一個API來使用Hibernate從數據庫中檢索記錄。如何從用戶定義的目錄中讀取休眠配置文件
例如我有一個API:
public List getUsers(String locationOfHibernateConfigFile) {
}
我試圖通過將配置文件的位置與使用c:\hibernate-cfg.xml
的完整路徑,如下所示:
SessionFactory sessionFactory = new Configuration()
.configure(C:\hibernate.cfg.xml).buildSessionFactory();
session = sessionFactory.openSession();
我正在一個錯誤說c:\hibernate-cfg.xml is not found
。
請給我一些指示,以實現相同。
@Carniel我嘗試了建議的方法,但沒有運氣。 – mohan
@mohan在classpath中是否有所有的hibernate庫?請檢查一下。把這個,目錄與所有jar:bytecode,jpa,可選,必需;和jars:hibernate3.jar,log4j.jar,slf4j-log4j12-1.6.2-sources.jar和slf4j-simple-1.6.2.jar。 –