我正在学习Java Hibernate但是得到下面列出的错误。你能帮我找一下我的错误吗?感谢。
Apr 11, 2017 11:32:46 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.9.Final}
Apr 11, 2017 11:32:46 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Failed to create sessionFactory object.org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml]
Exception in thread "main" java.lang.ExceptionInInitializerError
at testhibernate.ManageEmployee.main(ManageEmployee.java:20)
Caused by: org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml]
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:53)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
at testhibernate.ManageEmployee.main(ManageEmployee.java:17)
答案 0 :(得分:1)
将xml文件放在src-&gt; main-&gt; resources文件夹中。并且不要忘记将资源文件夹标记为来自IDE的资源。