Hibernate configuration files in another folder than src
I made a java application using the hibernate framework, with the xml files of hibernate in the src folder. Now, I moved the files in c开发者_Go百科onfig folder from my project, I changed the SessionFactoryUtil members to:
private static File f = new File("config/hibernate.cfg.xml");
private static SessionFactory sessionFactory = new Configuration().configure(f).buildSessionFactory();
And in the hibernate.cfg.xml I changed themappin resource to config/entities.hbm.xml
And now I have an exception:
org.hibernate.MappingNotFoundException: resource: config/entities.hbm.xml not found
Do you know a workaround?
This really depends on how your build is done. Most of the time it's you IDE which defines how your build is done.
If you use maven to build you can put the configuration in the folder named resources. If you use an IDE, you should try to find how your "config" folder can be added to the build path.
精彩评论