默认是“hibernate.cfg.xml”
所以你得使用
"config/hibernate.cfg.xml" 就可以了!

解决方案 »

  1.   

    不行
    org.hibernate.HibernateException: config/hibernate.cfg.xml not found
    org.hibernate.HibernateException: /config/hibernate.cfg.xml not found
    org.hibernate.HibernateException: /WEB-INF/config/hibernate.cfg.xml not foundHibernateSessionFactory在classes文件夹的com.xxx.hibernate包里
      

  2.   

    org.hibernate.HibernateException: /WEB-INF/config/hibernate.cfg.xml not found 
    =====================================================================================
    你不是说放到WEB-INF/config/目录里面的么?
    这个异常怎么报在里面没找到?
      

  3.   

    对阿 就是找不到文件
    我用
    new Configuration().configure("config/hibernate.cfg.xml")
    new Configuration().configure("/config/hibernate.cfg.xml")
    new Configuration().configure("/WEB-INF/config/hibernate.cfg.xml")
    这些路径都找不到
      

  4.   

    那你最好还是把配置文件放在src目录下,hibernate默认就往哪里找
    要不然把config文件夹都放在src目录下
      

  5.   


    所以就应该是:/config/hibernate.cfg.xml
      

  6.   

    放到src目录下的config目录下,可以这样:
    new Configuration().configure("config/hibernate.cfg.xml") ;
      

  7.   

    String path = "d:/test/WEB-INF/config/hibernate.cfg.xml ";//这里写绝对路径
    new Configuration().configure(path); 
      

  8.   


    this is a web project dao shu ru fa tu ran mei le
      

  9.   

    为什么要那么用啊,这样是不是很麻烦啊?直接放在classes下面就是了啊,写绝对路径的形式是要不得的
      

  10.   

    草~如果LZ真是要把Hibernate的配置文件放在WEB-INF/config/hibernate.cfg.xml 下!还真有个办法,不过个人认为好烦!就是从表现层传参数到业务层到数据访问层!就是定义一个传参数的方法获取SessionFactory!
    public SessionFactory getSessionFacory(String configPath){
                   Configuration con = new Configuration().configur(configPath+"/WEB-INF/config/hibernate.cfg.xml");
    SessionFactory sessionFactory = con.buildSessionFactory();
    }
    configPath就是从表现层传到数据访问层!
    其中 在表现层configPath = request.getContextPath();
      

  11.   

    最好是把XML 文件放到SRC 下面...方便使用..