HibernateException:找不到/hibernate.cfg.xml

时间:2018-05-22 19:24:21

标签: java hibernate exception

在我的servlet上工作时遇到了这个问题:

IDE tree view

org.hibernate.HibernateException: /hibernate.cfg.xml not found
    org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
    org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2093)
    org.hibernate.cfg.Configuration.configure(Configuration.java:2074)
    org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
    com.dede.app1st.controller.AddUser.doPost(AddUser.java:26)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

1 个答案:

答案 0 :(得分:1)

hibernate.cfg.xml似乎在类路径根目录中搜索,但位于子包com.dede.app1st.controller中。将它移动到root包应该可以解决问题。