2015-10-31 2 views
0

Я создал простой проект с использованием Maven Hibernate, но проект дает мне следующую ошибку:Initial failed./resources/hibernate.cfg.xml SessionFactory создание не найден

Initial SessionFactory creation failed./resources/hibernate.cfg.xml not  found 
org.hibernate.HibernateException: /resources/hibernate.cfg.xml not found 
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170) 
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453) 
at org.hibernate.cfg.Configuration.configure(Configuration.java:1475) 
at Code.CourseDaoImp.<clinit>(CourseDaoImp.java:16) 
at Code.CourseServiceImp.processCourse(CourseServiceImp.java:10) 
at Code.app.main(app.java:21) 
Exception in thread "main" java.lang.ExceptionInInitializerError 
at Code.CourseDaoImp.<clinit>(CourseDaoImp.java:22) 
at Code.CourseServiceImp.processCourse(CourseServiceImp.java:10) 
at Code.app.main(app.java:21) 
Caused by: org.hibernate.HibernateException: /resources/hibernate.cfg.xml not found 
at   org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170) 
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453) 
at org.hibernate.cfg.Configuration.configure(Configuration.java:1475) 
at Code.CourseDaoImp.<clinit>(CourseDaoImp.java:16) 
... 2 more 

enter image description here

ответ

1
  • Перемещение Источники Java в SRC/основной/Java
  • * .xml в SRC/основные/ресурсов

To meet the standards of MAVEN , like that XML will be added automatically at CLASSPATH

1

ресурсы является одним из исходную папку вашего проекта. Это означает, что все, что он содержит, находится в роере пути classpath (в пакете по умолчанию). Таким образом, код нужно

sessionFactory = new Configuration().configure("hibernate.cfg.xml"); 
Смежные вопросы