我使用Maven Hibernate创建了Simple项目,但是项目给了我以下错误:
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
答案 0 :(得分:1)
resources是您项目的sources文件夹之一。这意味着它包含的所有内容都在类路径的roor中(在默认包中)。所以你需要的代码是
<div class="someclass1">
<div class="someclass2">
<div class="form-group">
<input type="text" class="sequence valid">
</div>
</div>
</div>
答案 1 :(得分:1)
要符合MAVEN标准,就像添加XML一样 自动在CLASSPATH