Meavn 搭建项目遇到Error creating bean with name 'sessionFactory' defined in class path resource
2017-11-18 14:34
706 查看
Error creating bean with name 'sessionFactory' defined in class path resource 。nested exception is java.io.FileNotFoundException: class path resource [com/test/domain/Department.bhm.xml]
原错误大意为 : Spring初始化 applicationContext 失败,在初始化 sessionFactory 时 失败,因为没有找到 *.hbm.xml 文件。
原因是:编译后的文件中确实没找到 *.hbm.xml 文件。
解决方法:
1. 手动复制 *.hbm.xml 文件到编译后的目标目录(治标不治本,但较为简单)
2. 在 pom.xml 中文件中增加一段代码。
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.hbm.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
添加的时候注意有没有这些标签,没有的话直接放在 <build></build>中即可,如果有,放在相对应的位置,如<resources></resources>中,此时注释掉这段代码的<resources></resources>
原错误大意为 : Spring初始化 applicationContext 失败,在初始化 sessionFactory 时 失败,因为没有找到 *.hbm.xml 文件。
原因是:编译后的文件中确实没找到 *.hbm.xml 文件。
解决方法:
1. 手动复制 *.hbm.xml 文件到编译后的目标目录(治标不治本,但较为简单)
2. 在 pom.xml 中文件中增加一段代码。
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.hbm.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
添加的时候注意有没有这些标签,没有的话直接放在 <build></build>中即可,如果有,放在相对应的位置,如<resources></resources>中,此时注释掉这段代码的<resources></resources>
相关文章推荐
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource
- Bug--Error creating bean with name 'sessionFactory' defined in class path resource [data_context.xml
- Error creating bean with name 'sessionFactory' defined in class path resource
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- ssm出现Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applic
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- FAQ(27):Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicatio
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sqlSessionFactory' defined in class path resource
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocatio
- IDEA 启动 Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-m
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationC
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sqlSessionFactory' defined in class path resource