Location of hibernate.cfg.xml in project?

前端 未结 10 1782
盖世英雄少女心
盖世英雄少女心 2020-11-27 07:28

I created a project with following structure:

\"enter

HibernateUtil:



        
10条回答
  •  眼角桃花
    2020-11-27 07:55

    In case of a Maven Project, create a folder named resources under src/main folder and add the resources folder as a source folder in your classpath.

    You can do that by going to Configure Build Path and then clicking Add Folder to the Sources Tab.

    Then check the resources folder and click Apply.

    Then just use :

    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    

提交回复
热议问题