Where to place hibernate.cfg.xml?

前端 未结 9 842
渐次进展
渐次进展 2020-12-02 22:40

My project is like this:

/src/main/java
     -thegamers
         -app.java
         -hibernateutil.java

can someone tell me where to put th

相关标签:
9条回答
  • 2020-12-02 23:03

    try to place it into "src/main/resources" directory.

    0 讨论(0)
  • 2020-12-02 23:06

    If you are using Eclipse, go to Project -> Properties -> Java Build Path -> Source. You can add the new folder where you placed the file, or move the file to the existing folder.

    0 讨论(0)
  • 2020-12-02 23:09

    The file is suppose to go into the root of your /src dir, while /src is not deployed, everything in it is built/copied out to WEB-INF/classes which IS deployed. Hibernate needs the cfg.xml file in the classpath of your project to load its config settings, your WEB-INF dir is not in your classpath, so if you were to put it there, you'd be hiding it from Hibernate and it wouldn't work.

    This thread would tell you how to load the hibernate.cfg.xml from any different path.

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