|
做hibernate的小練習(xí),對(duì)configuration的configure()方法很好奇,為啥創(chuàng)建的對(duì)象還要執(zhí)行這個(gè)方法呢。 Configuration cfg = new Configuration().configure(); 原來configure()方法默認(rèn)會(huì)在classpath下面尋找hibernate.cfg.xml文件,如果沒有找到該文件,系統(tǒng)會(huì)打印如下信息并拋出HibernateException異常。 其實(shí)不使用configure()方法也可以Configuration cfg = new Configuration();這時(shí)hibernate會(huì)在classpath下面尋找hibernate.properties文件,如果沒有找到該文件,系統(tǒng)會(huì)打印如下信息并拋出HibernateException異常。 |
|
|