org.hibernate.HibernateException: /hibernate.cfg.xml not found

前端 未结 7 1026
野趣味
野趣味 2020-12-03 15:22

I\'m trying to use hibernate with spring 3 mvc but at the moment I get this exception thrown. I think I need to define my hibernate.cfg.xml somewhere, but not s

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 15:56

    If you using Maven you should put file hibernate.cfg.xml in following path /src/main/java/resources/hibernate.cfg.xml in Intellij IDEA. Then, in your run application class just insert line:

    SessionFactory factory = new Configuration().configure("hibernate.cfg.xml").addAnnotatedClass().buildSessionFactory();

提交回复
热议问题