Mybatis 无法加载对应的Mapping映射文件
来源:互联网 发布:视频直播美颜软件 编辑:程序博客网 时间:2024/05/21 08:45
错误: tomcat启动报错日志
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mall.dao.hospital_card.HospitalCardDao com.mall.service.impl.hospitalCard.HospitalCardServiceImpl.hospitalCardDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hospitalCardDao' defined in URL [jar:file:/D:/Work/Working/WorkSpace/Idea/llam/mall/mall_admin/target/mall_admin/WEB-INF/lib/mall_core-0.0.1-SNAPSHOT.jar!/com/mall/dao/hospital_card/HospitalCardDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\Work\Working\WorkSpace\Idea\llam\mall\mall_admin\target\mall_admin\WEB-INF\classes\config\spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [org.springframework.core.io.Resource[]] for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:/com/mall/mapping/*/*.xml]: class path resource [com/mall/mapping/] cannot be resolved to URL because it does not exist at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ... 58 more
原因:
一直是不能创建bean的样子,经过一行一行地阅读报错信息。最后发现mybatis的映射xml文件居然没有找到,然后又去翻classes目录,结果果然没有,因为自己的mybatis的mapping目录是在src/main/java 在编译时没有保留配置文件,导致tomcat启动无法找到对应的目录从而报错
解决办法:
在pom文件中加入如下代码:
<build> <resources> <!--编译之后包含xml--> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources></build>
阅读全文
0 0
- Mybatis 无法加载对应的Mapping映射文件
- MyBatis自动生成实体类、DAO接口和Mapping映射文件的代码(逆向工程)
- 利用mybatis-generator自动生成JavaBean,mapping映射文件等
- MyBatis自动生成实体、DAO接口、Mapping映射文件
- mybatis查询的时候xml文件中没有对应的sql映射文件
- mapping--映射文件--详解
- Activiti 5.17 的Mybatis Mapping文件
- mybatis如何自动生成实体类,映射文件以及对应的dao层
- 在eclipse中使用MyBatis Geneator自动生成出对应数据库的实体与映射文件
- MyBatis对应xml映射文件l配置例子
- MyBatis的XML映射文件、映射器
- mybatis的xml映射文件**
- 使用Mybatis生成工具自动生成实体类和对应的mapper映射文件以及接口文件
- course类对应的映射文件
- 内存映射文件File Mapping
- mybatis的mapper映射文件的加载(resource方式,class方式,以及包扫描)
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- MyBatis Review——加载mappers映射文件的三种方式
- [NYOJ1282]部分和问题(入门题)
- 基于CUCM的思科设备的呼叫转移主叫和被叫问题
- 如何在Webstorm/Phpstorm中设置连接FTP,并快速进行文件比较,上传下载,同步等操作
- [MySQL] CentOS7 mysql5.7 忘记root密码 重置root密码 1045
- Shader小常识之——法线纹理在切线空间下的存储
- Mybatis 无法加载对应的Mapping映射文件
- kotlin学习-基本语法(二)
- GoEasy免费推送服务
- ActiveMq 使用例子
- [TYVJ1143]飘飘乎居士的约会
- 开源库LitePal
- pyyhon scrapy爬虫基础知识
- Oracle EBS应付发票验证不了:Invoice Validation Errors with The sum of the Percentage Recovery Rates is great
- Java Agent调试