Search code examples
javahibernatehibernate-annotations

How to load hibernate.cfg.xml file in the java standalone application


I am writing java standalone application with hibernate annotations.I am placing "hibernate.cfg.xml" file inside src directory. During startup,I am creating session factory using

sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

I am using ant build script to make compile and creating jar file. When running my application, getting error

"org.hibernate.HibernateException: /hibernate.cfg.xml not found"

Please let me know where to place this file and how to fix this error


Solution

  • According to your description place it in the folder above the src folder.