Location of hibernate.cfg.xml in project?

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

I created a project with following structure:

\"enter

HibernateUtil:



        
10条回答
  •  佛祖请我去吃肉
    2020-11-27 07:42

    Somehow placing under "src" folder didn't work for me.

    Instead placing cfg.xml as below:

    [Project Folder]\src\main\resources\hibernate.cfg.xml
    

    worked. Using this code

    new Configuration().configure().buildSessionFactory().openSession();
    

    in a file under

        [Project Folder]/src/main/java/com/abc/xyz/filename.java
    

    In addition have this piece of code in hibernate.cfg.xml

    
    
    

    Placed the above hbm.xml files under:

    EDIT:

    [Project Folder]/src/main/resources/hibernate/Address.hbm.xml
    [Project Folder]/src/main/resources/hibernate/Person.hbm.xml
    

    Above structure worked.

提交回复
热议问题