maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
来源:互联网 发布:数据库人员报表查询 编辑:程序博客网 时间:2024/06/06 01:11
刚开始学习Maven,学习过程中遇到了很多问题,尤其是使用Eclipse创建Maven工程,真TM蛋疼。。。
按照网上的教程创建了一个Maven项目,看一下项目结构:
请注意,我的配置文件没有放到src/main/resource文件夹下。
结果运行之后就会报错:
org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found。
网上查了半天资料,原来对于Maven工程,编译的工作是由Maven程序来完成的,而Maven默认只会把src/main/resources文件夹下的文件拷贝到target/classes文件夹下,所以上图中用红框框起来的.hbm.xml都不会被复制到/target/calsses文件夹下,所以Hibernate框架在运行的时候,就会报找不到*.hbm.xml的错误。
解决方案:
在pom.xml中显式地告诉Maven把什么资源文件复制到target/classes文件夹下。
如下代码:
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> </resources></build>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
相关问题:Maven项目编译后class文件没有.xml文件问题。
阅读全文
0 0
- maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- Hibernate 出现org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- org.hibernate.MappingNotFoundException: resource: xxx.hbm.xml not found
- org.hibernate.MappingNotFoundException: resource: entity.Students.hbm.xml not found
- Hibernate错误 org.hibernate.MappingNotFoundException: resource: com/com/Person.hbm.xml not found
- 配置jbpm环境时,出现org.hibernate.MappingNotFoundException: resource: jbpm.repository.hbm.xml not found
- Caused by:org.hibernate.MappingNotFoundException:resouce:com/you/model/Monkey.hbm.xml not found
- resource: ****.hbm.xml not found解决方案
- Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found : com/itcast/j
- hibernate5 报错org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found
- Maven项目总是出现org.hibernate.HibernateException: /hibernate.cfg.xml not found错误的解决方法
- Resource: bean/Product.hbm.xml not found
- org.hibernate.boot.MappingNotFoundException解决方案
- 解决IDEA使用hibernate出现*.hbm.xml not found的问题
- Hibernate问题之Maven项目不打包*.hbm.xml文件
- resource: *********.hbm.xml not found 这个错误完美解决
- 音频录制以及播放
- 《Angular之表格选中跳转》
- EM算法
- 数据结构实验之二叉树四:(先序中序)还原二叉树
- hdu 5718 oracle
- maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- C/C++:计算器
- NOIP2017普及组T1题解
- Windows程序设计(3):程序启动器(CreateProcess)
- hdu 4403 A very hard Aoshu problem
- 素数求和问题
- 熔断器 Hystrix 源码解析 —— 调试环境搭建
- iOS 一一 手势解锁
- 可变参数列表