Where to place hibernate.cfg.xml?

前端 未结 9 880
渐次进展
渐次进展 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: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.

提交回复
热议问题