maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
来源:互联网 发布:手机信号稳定软件 编辑:程序博客网 时间:2024/06/06 04:00
刚开始学习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>
相关问题:Maven项目编译后class文件没有.xml文件问题。
1 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 这个错误完美解决
- swift与枚举
- 怎样寻找可使用的联通宽带账号及密码
- Java线程的5个使用技巧
- 《More Effective C++ 35个改善编程与设计的有效方法》——第一章笔记
- Ubuntu + coreseek + python + mysql (二、配置数据源和索引)
- maven项目中 org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
- 为什么要使用Serializable接口?
- 我看“柴静雾霾调查:穹顶之下 同呼吸 共命运”后感
- httpclient返回xml
- OPENCV之Mat类详解
- C++ auto_ptr智能指针的用法
- java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException 的解决办法
- MM模块-收货自动创建采购订单
- C#集合类