org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bireportSqlSessionFactory' defined in URL
报错如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bireportSqlSessionFactory' defined in URL [file:/D:/devcode/apstart/bireport/bireport-center/target/bireport-center/WEB-INF/classes/spring/spring-bireport-db.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\devcode\apstart\bireport\bireport-center\target\bireport-center\WEB-INF\classes\com\apstar\bireport\mapper\demo.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Mapper's namespace cannot be empty
1.刚开始的时候,怀疑是mybatis的bean有问题,更换了名称,不行。
2.然后查看资料,尝试在pom里面放入依赖包,但工程发现已经下载有了mybatis的两个包,所以排除。
3.检查我的mybatis-config.xml配置文件,也没问题,排除。
4.结果发现:我使用了p:mapperLocations 所以,mybatis会扫描我的mapper的xml文件,如果没有它,会报bean错误
在我的mapper层下的xml文件,必须要建有,并且是有mybatis的头引用,并且<mapper...><.mapper>内容不能为空。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.apstar.bireport.dao.DemoDao"> <select id="selectDemo" parameterType="com.apstar.bireport.po.DemoPo"
resultType="com.apstar.bireport.po.DemoPo"></select>
</mapper>
我的mybatis配置如下 :
<!-- mybatis配置 -->
<!-- mybatis文件配置,扫描所有mapper文件 -->
<bean id="bireportSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="bireportDataSource" p:configLocation="classpath:mybatis/mybatis-config.xml"
p:mapperLocations="classpath*:com/apstar/bireport/mapper/*.xml"
p:typeAliasesPackage="com.apstar.bireport.po"/>
<!-- mybatisDAO配置 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.apstar.bireport.dao"/>
<property name="sqlSessionFactoryBeanName" value="bireportSqlSessionFactory"/>
</bean>
参考了:https://blog.csdn.net/ljm15832631631/article/details/79346279
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bireportSqlSessionFactory' defined in URL的更多相关文章
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'needDao' defined in URL
这个是我修改过后的mapper,是我的mapper中的空间地址写错了呢
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r ...
- 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class p
严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener]org.springframework ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardSalDao' defined in file [E:\GItUp\pointerCard+redis\target\gameCard-1.0-SNAPSHOT\WEB-INF\classes\cn\jbit\dao
错误信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardSa ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined ...
- aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...
- Spring AOP 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource..........
完整报错如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'befo ...
- 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]
报这种错的原因基本上是applicationContext.xml文件中bean配置错误,错误如下: org.springframework.beans.factory.BeanCreationExc ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is
在复制xml文件进行修改的时候,我经常将不小心对原文件进行修改,而导致创建bean出错.报错如下所示: Exception sending context initialized event to l ...
随机推荐
- Linux上mysql修改密码
http://www.cnblogs.com/wangjiangze/archive/2011/03/03/1970105.html MySQL中修改密码及访问限制设置详解
- x264 编码数配置
记录项目中用到一组x264快速编码参数配置,具体如下: param->i_frame_reference = 1; param->i_scenecut_threshold = 0; par ...
- 无线热点登陆认证原理探究---captive portal
什么是Captive Portal 大家肯定都连过公共场所的wifi热点,比如麦当劳等地方的.他们的wifi往往一连上去就会弹出一个要求登录或者微信关注之类的页面,只有在这个页面完成操作了才能正常访问 ...
- App性能优化浅谈
前言 前段时间给公司的小伙伴们进行了关于app性能优化的技术分享.这里我稍微整理一下也给大家分享一下.关于性能优化这个话题非常大,涉及面能够非常广,也能够非常深入.本人能力有限,不会给大家讲特别难懂, ...
- caffe搭建--缺少 skimage-缺少 google.protobuf.internal.-caffe搭建--ipython--ubuntu16.04+ caffe+ ipython
mkdir build && cd build cmake .. make pycaffe -j4 sudo vim /etc/profile---- export PYTHONPAT ...
- oracle死锁的检测查询及处理
-- 死锁查询语句 SELECT bs.username "Blocking User", bs.username "DB User", ws.username ...
- MySQL 启动报错:File ./mysql-bin.index not found (Errcode: 13)
Linux下安装初始化完MySQL数据库之后,使用mysqld_safe启动mysql数据库,如下发现,启动失败 [root@SVNServer bin]# ./mysqld_safe –user=m ...
- disabled和readonly
项目中,有一个input控件,input的值需要通过点击一个javascript链接,从弹出的对话框中所列出的项中选择.而不能从input框中直接输入. 刚开始将input的disabled属性设置为 ...
- Hibernate表关系映射之一对一映射
一.数据表的映射关系 在数据库领域中,数据表和数据表之间关系一般可以分为如下几种: 一对一:比如公民和身份证的关系,一个人只有一张身份证,同时每张身份证也仅仅对应一个人! 一对多:比如客户和订单之间的 ...
- eacharts 根据后台数据生成柱状图
说明:开发环境vs2012 ,asp.net mvc4项目,c#语言 1.效果图 2.HTML 前端代码 <%@ Page Language="C#" AutoEventWi ...