hibernate.cfg.xml of Hibernate

前端 未结 2 443
旧巷少年郎
旧巷少年郎 2021-01-27 09:23

In my Java Project, hibernate.cfg.xml is sitting in the source folder-- \\src. So, to be precise, it is a file in the source folder, sitting right next to the

2条回答
  •  悲哀的现实
    2021-01-27 10:20

    By default hibernate will look at hibernate.cfg.xml on your classpath root. If you're packaging a jar, this is typically right at the top level. For war, typically on WEB-INF/classes.

    If you eclipse is set with src folder as a source directory then it should be fine, just double check the generated war/jar has this file at correct location

    Try refreshing / cleaning your eclipse project as often the resource is out of sync with file system.

    Also have a look at Configuration class, it has configure(String) method to specify a custom location

提交回复
热议问题