hibernate中Configuration configuration=new Configuration().configure();默认读取的是hibernate.cfg.xml文件,怎么让它去读取applicationContext.xml,SH结合使用

来源:学生作业帮助网 编辑:作业帮 时间:2024/10/05 12:01:04
hibernate中Configuration configuration=new Configuration().configure();默认读取的是hibernate.cfg.xml文件,怎么让它去读取applicationContext.xml,SH结合使用
xՐJ`oC1/ $ν)6\dgsKT4:H3Mj:7EIt8>RL)<^bBH^Ȝ"@ב_|гxW$]sI6{" o QhS \"$_ W>LԵopSGm19k~ٟPHfY*՟I-QI$+81Ut<n} |deQֵ Rlbjcxe7q?#xc,d%1. #g2?JZ*NmUQsOG9ؽX'9W nI{!j2QF^9č KLV-?է e$NA?R

hibernate中Configuration configuration=new Configuration().configure();默认读取的是hibernate.cfg.xml文件,怎么让它去读取applicationContext.xml,SH结合使用
hibernate中Configuration configuration=new Configuration().configure();
默认读取的是hibernate.cfg.xml文件,怎么让它去读取applicationContext.xml,SH结合使用

hibernate中Configuration configuration=new Configuration().configure();默认读取的是hibernate.cfg.xml文件,怎么让它去读取applicationContext.xml,SH结合使用

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

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

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


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