ITeye博客

hibernate的Configuration对象的configure()方法的作用

孙健坤 · 2009-11-15 15:56 · hibernate · Markdown

做hibernate的小练习,对configuration的configure()方法很好奇,为啥创建的对象还要执行这个方法呢。

Configuration cfg = new Configuration().configure();

原来configure()方法默认会在classpath下面寻找hibernate.cfg.xml文件,如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常。

其实不使用configure()方法也可以Configuration cfg = new Configuration();这时hibernate会在classpath下面寻找hibernate.properties文件,如果没有找到该文件,系统会打印如下信息并抛出HibernateException异常。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。