hibernate中Configuration configuration=new Configuration().configure();

2025-04-08 19:40:43
推荐回答(1个)
回答1:

。。一般有了Spring的话都轮不到hibernate.cfg.xml出现了吧,主流思路是

  1. 把hibernate的配置集成到applicationContext.xml中。

  2. 把hibernate.cfg.xml注入到sessionFactory里。


如果你要用Configuration,configure方法有个参数,可以指定路径的。不过应该只能读取hibernate.cfg.xml而不是applicationContext.xml