ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml] in project root folder

后端 未结 6 1373
萌比男神i
萌比男神i 2021-01-02 09:38

I have the hibernate.cfg.xml file in the project root folder.

If I run an application containing:

SessionFactory s         


        
相关标签:
6条回答
  • 2021-01-02 09:53

    It must be added to the configuration file as a persistence type.

    Project Settings > Facets > Add Hibernate > Config Path

    And you can see it configured in View > Tools Windows > Persistence

    GL

    0 讨论(0)
  • 2021-01-02 10:04

    Use forward / to put cfg file without forward / it won't work

    0 讨论(0)
  • 2021-01-02 10:09

    If you are using Maven to build your project, place the 'hibernate.cfg.xml' file under 'src/main/resources'

    0 讨论(0)
  • 2021-01-02 10:11

    If you are using Maven as build tool then place hibernate.cfg.xml under resources folder.

    Steps to make application refer Hibernate Configuration File.

    Right click the resources folder and select Mark Directory As option and click on Resources Root.

    These steps worked for me in InteliJ IDEA Ultimate 14.

    0 讨论(0)
  • 2021-01-02 10:14

    The hibernate.cfg.xml file should be moved to src folder.

    0 讨论(0)
  • 2021-01-02 10:15

    I was also facing the similar issue, and I noticed that my hibernate configuration file "hibernate.cfg.xml" was not on the required path. Hence I moved hibernate.cfg.xml into src folder and that resolved the issue.

    0 讨论(0)
提交回复
热议问题