Location of hibernate.cfg.xml in project?

前端 未结 10 1776
盖世英雄少女心
盖世英雄少女心 2020-11-27 07:28

I created a project with following structure:

\"enter

HibernateUtil:



        
10条回答
  •  [愿得一人]
    2020-11-27 07:46

    Another reason why this exception occurs is if you call the configure method twice on a Configuration or AnnotatedConfiguration object like this -

    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass(MyClass.class);
    //Use this if config files are in src folder
    config.configure();
    //Use this if config files are in a subfolder of src, such as "resources"
    config.configure("/resources/hibernate.cfg.xml");
    

    Btw, this project structure is inside eclipse.

提交回复
热议问题