报错如下:

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的更多相关文章

  1. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'needDao' defined in URL

    这个是我修改过后的mapper,是我的mapper中的空间地址写错了呢

  2. 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 ...

  3. 异常将上下文初始化事件发送到类的侦听器实例.[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 ...

  4. 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 ...

  5. 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 ...

  6. 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' ...

  7. 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 ...

  8. 报错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 ...

  9. 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 ...

随机推荐

  1. C#自定义类型数组排序

    在数组或者集合中对自定义类型进行排序分为两种方法. 1.如果这个自定义类型是自己定义编写的,那么我可以使它继承ICompareable<T>接口,实现其中的CompareTo(Object ...

  2. poj 1703 Find them, Catch them(种类并查集和一种巧妙的方法)

    Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36176   Accepted: ...

  3. 腾讯云centos,nginx安装

  4. angular cannot get /

    每次遇到这问题都一脸懵逼,好像自己啥都没改咋就悲剧了 目前知道的办法是在命令行运行ng serve,它会告诉你详细错误 因为我是通过asp.net core的集成环境运行的,它没显示出详细错误

  5. wpf Style也继承(包含内部定义事件)

    如何在既定皮肤下为某个style添加内容是我今天碰的问题,皮肤往往是对全局control进行设置的,当然这就无法满足某个个性十足的“另类”了,比如当使用DataGridCheckBoxColumn时, ...

  6. Nginx下的https配置

    https: https(Secure Hypertext Transfer Protocol) 安全超文本传输协议 它是以安全为目标的http通道,即它是http的安全版.它使用安全套接字层(SSL ...

  7. 【BZOJ3041】水叮当的舞步 迭代深搜IDA*

    [BZOJ3041]水叮当的舞步 Description 水叮当得到了一块五颜六色的格子形地毯作为生日礼物,更加特别的是,地毯上格子的颜色还能随着踩踏而改变.为了讨好她的偶像虹猫,水叮当决定在地毯上跳 ...

  8. 【BZOJ3837】[Pa2013]Filary 随机化神题

    [BZOJ3837][Pa2013]Filary Description 给定n个正整数,从中挑出k个数,满足:存在某一个m(m>=2),使得这k个数模m的余数相等. 求出k的最大值,并求出此时 ...

  9. 开源G711A/PCMA、G711U/PCMU、G726、PCM转码AAC项目EasyAACEncoder

    项目及源码地址:https://github.com/EasyDarwin/EasyAACEncoder EasyAACEncoder 是EasyDarwin开源流媒体服务团队整理.开发的一款音频转码 ...

  10. c/c++预处理命令#pragma

    1 #pragma pack(push, 1)和#pragma pack(pop) #pragma pack用于指定数据在内存中的对齐方式.如果不指定对齐方式的话,默认为自然对齐. 1.1 #prag ...