项目场景:

Mybatis

问题描述:

org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in com/itrs/mapper/UserMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/itrs/mapper/UserMapper.xmlat org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)at com.itrs.test.MybatisTest.test1(MybatisTest.java:21)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.base/java.lang.reflect.Method.invoke(Method.java:566)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.junit.runner.JUnitCore.run(JUnitCore.java:137)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/itrs/mapper/UserMapper.xmlat org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:121)at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:98)at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78)... 24 more
Caused by: java.io.IOException: Could not find resource com/itrs/mapper/UserMapper.xmlat org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:114)at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:100)at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:372)at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:119)... 26 more

原因分析:

其他方法无果后: 发现文件路径问题


解决方案:

在resources下创建文件的时候使用以下方法创建

不要写成com.xx.mapper.xxxxx.xml

### Error building SqlSession. ### The error may exist in com/itrs/mapper/UserMapper.xml ### Cause:相关推荐

  1. ### Error building SqlSession.### The error may exist in entity/UserMapper.xml

    错误样式: 核心错误提示: ### Error building SqlSession. ### The error may exist in entity/UserMapper.xml 原因:就是M ...

  2. Error building SqlSession. ### The error may exist in com/itrs/mapper/OrderMapper.xml ### The error

    报错信息 org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error ...

  3. Error building SqlSession.The error may exist in cn/library/mapper/UserMapper.xml(Mybatis搭建测试中的错误解决)

    一.问题详情 IDEA2019中在搭建Mybatis简化DAO操作时报错: 错误分析:初步判断存在于配置文件UserMapper.xml中. 错误详情: org.apache.ibatis.excep ...

  4. org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may

    报错显示: org.apache.ibatis.exceptions.PersistenceException: Error building SqlSession. The error may ex ...

  5. ### The error may exist in com/itheima/mapper/UserMapper.xml ### Cause: org.apache.ibatis.builder.Bu

    解决办法: 在sqlMapConfig.xml文件中,配置mapper,加载映射文件时,路径写的有问题,解决办法是找到UserMapper.xml文件,并且鼠标右键选择Copy Relative Pa ...

  6. ### Error building SqlSession. ### Cause: org.apache.ibatis.builder.BuilderException: Error creating

    mybatis报错: ###Error building SqlSession. ###Cause: org.apache.ibatis.builder.BuilderException: Error ...

  7. Error building SqlSession问题

    1.mybatis核心文件没有配置好 甚至是mapper的位置是否放置好也会导致 所以注意自己配置时候的核心文件是否正确 2.返回的结果类型没配置好 返回结果的权限在设置的时候应当选择该包所在的位置, ...

  8. The error may exist in com/kuang/dao/UserMapper.xml

    问题原因:在java包下创建了xml文件,但是maven运行时候是找的resource文件下的配置文件,不能导入java包下的配置文件, 解决办法: pom文件中添加配置信息,就能找到配置文件了: & ...

  9. The error may exist in XX/XXX/mapper/XXXMapper.xml的解决方法

    使用mybatis框架,在连接数据库进行添加用户时,出现了问题,如下:(关键部分已用红框标出) 于是我去XXMapper.xml文件中检查代码,发现是sql语句中"values(a,b,c) ...

最新文章

  1. 算法笔记--单调队列优化dp
  2. 使用舵机PWM信号控制直流电机的转动
  3. 中科院自动化所:最新视觉-语言预训练综述
  4. 【工业控制】UV打印机喷头波形和墨水关系
  5. 【MySQL】性能优化之 straight_join
  6. ab压力测试_Apache ab压力测试的知识点
  7. gdb调试的基本使用
  8. 95-40-014-生产者-KafkaProducer
  9. php 清除指定session,PHP如何操作指定的session?
  10. undefined reference to `inflateInit2_'
  11. 学生a3制图标题栏尺寸手绘_机械制图基础知识学习,如何画好一张零件图?
  12. 电机扭矩计算机公式由来T=9950*P/
  13. 三角形求高公式计算机,直角三角形求高公式 直角三角形怎么求高
  14. SpringBoot:EasyExcel动态字段(不创建对象)多sheet、多文件|压缩包格式导出
  15. 微信小程序之回调函数
  16. 微生物群落组装过程(assembly processes)
  17. 腾讯游戏扫码登录源码
  18. 使用数字陷波器滤除工频信号
  19. oracle sql数据计算精度问题
  20. ohos-build 安装失败分析

热门文章

  1. 学习分享:学术前言趋势分析3—论文代码统计
  2. 复杂的事情简单做,你就是专家; 简单的事情重复做,你就是行家; 重复的事情用心做,你就是赢家。...
  3. libreoffice命令行方式将word、excel、ppt转成pdf
  4. 国内互联网公司的薪酬、加班时长排名 !
  5. 三菱mode bus tcp通讯_三菱E-700变频器按键英文翻译及特点讲解
  6. 微信小程序实现音频播放
  7. selenium使用账号密码模拟登陆淘宝,使用账号密码!
  8. 有了这个办法,跑AI任务再也不用在机器上插GPU卡了
  9. Trunk与三层交换机技术
  10. 在IntelliJ IDEA中Tomcat的配置过程(全程详细图解)