spring mybatis错误问题该怎么解决
1.org.apache.ibatis.exceptions.PersistenceExc
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in cn.itcast.mybatis.mapper/UserMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource cn.itcast.mybatis.mapper/UserMapper.xml
出现这个问题大多数都是找不到映射文件,这和没有遵循mybatis的mapper代理配置规范有关,对于我这个问题仔细看java.io.IOException:Could not find resource
cn.itcast.mybatis.mapper/UserMapper.xml,就是文件读写出现问题,系统找不到这个文件,需要检查,mapper接口与映射的mapper.xml 的命名是否一致,是否在同一目录下。
如果还没解决就在看SqlMapConfig.xml配置文件加载mapper接口文件的路径有没有错误,一般有两种方试,第一扫描类<mapper class=:"类路径和类名"/>第二种批量扫描加载:选择扫描包<package name="包名"/>经过不懈努力问题终于解决。我们在开发mybatis时要注意四点开发规范:
、在mapper.xml中namespace等于mapper接口地址
、mapper.java接口中的方法名和mapper.xml中statement的id一致 、mapper.java接口中的方法输入参数类型和mapper.xml中statement的parameterType指定的类型一致。 、mapper.java接口中的方法返回值类型和mapper.xml中statement的resultType指定的类型一致。
spring mybatis错误问题该怎么解决的更多相关文章
- maven,spring,mybatis集成错误
maven,spring,mybatis集成的时候单元测试junit测试没问题,但mvn jetty:run 就报错误 错误: org.apache.ibatis.binding.BindingExc ...
- spring整合mybatis错误:Could not autowire field: com.kjczwl.ssm.service.ItemsService com.kjczwl.ssm.controller.ItemsController.itemsservice;
运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse 错误:Could not autowire field: com.kj ...
- maven工程下整合spring+mybatis报Mapped Statements collection does not contain value for spring-mybatis-user-get错误
在整合spring+mybatis报了下面的错误: Mapped Statements collection does not contain value for spring-mybatis-use ...
- spring + myBatis 常见错误:注解事务不回滚
最近项目在用springMVC+spring+myBatis框架,在配置事务的时候发现一个事务不能回滚的问题. 刚开始配置如下:springMVC.xml配置内容: spring.xml配置内容 从上 ...
- spring + myBatis 常见错误:@Autowired注解失败
今天配置spring+myBatis的时候,使用注解@Autowired把持久层dao注入service层的时候总是报错. 查了好久才发现,居然是配置文件路径写错了.basepackge的路径一定要正 ...
- Maven 搭建SpringMvc+Spring+Mybatis详细记录
总觉得,看比人写的总是那么好,每次搭建框架时都会找博客,找教程来跟着一步一步走,虽然很快搭建成功了,但是经常情况是我并不知道我干了什么,也不记得具体步骤,到底为什么要这么做,今天我详细记录了一下自己搭 ...
- idea+springmvc+spring+mybatis+maven整合返回json数据webapi
首先看一张目录结构图: : 创建步骤: 1.创建maven webapp工程, 创建完后的目录结构为: 2.添加项目依赖(添加jar包) 需要的jar包: spring-webmvc, spring ...
- SSM 即所谓的 Spring MVC + Spring + MyBatis 整合开发。
SSM 即所谓的 Spring MVC + Spring + MyBatis 整合开发.是目前企业开发比较流行的架构.代替了之前的SSH(Struts + Spring + Hibernate) 计划 ...
- Spring MVC+Spring+Mybatis+MySQL(IDEA)入门框架搭建
目录 Spring MVC+Spring+Mybatis+MySQL(IDEA)入门框架搭建 0.项目准备 1.数据持久层Mybatis+MySQL 1.1 MySQL数据准备 1.2 Mybatis ...
随机推荐
- 基于CAS实现无锁结构
杨乾成 2017310500302 一.题目要求 基于CAS(Compare and Swap)实现一个无锁结构,可考虑queue,stack,hashmap,freelist等. 能够支持多个线程同 ...
- NLP之预训练
内容是结合:https://zhuanlan.zhihu.com/p/49271699 可以直接看原文 预训练一般要从图像处理领域说起:可以先用某个训练集合比如训练集合A或者训练集合B对这个网络进行预 ...
- day 29
Let the dead have the immortality of fame, but the living the immortality of love. 让逝者拥有不朽的荣誉,让生者拥有不 ...
- [LeetCode] 236. Lowest Common Ancestor of a Binary Tree 二叉树的最小共同父节点
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...
- div 中 id 和 class使用详解【转】
原文地址:https://blog.csdn.net/zxw136511485/article/details/71191053 在div 标签中,我们比较常见的属性是id 和class,那么这两个属 ...
- java web开发入门七(mybatis)基于intellig idea
mybatis 一. 入门开发步骤 1.导入相关jar包 mybatis3.4.2核心开发包 asm-5.1.jarcglib-3.2.4.jarcommons-logging-1.1.3.jarlo ...
- 解决IDEA卡顿的问题(Windows和Mac)
IDEA卡顿 最近一段时间经常会在开发的时候感觉到 IDEA 很卡,在一个类里上下滚动或者切换类文件时都能够明显的感觉到,我以为是我项目打开的太多了,毕竟内存优化已经做过了,但是今天实在是被这玩意儿卡 ...
- 去掉DataGridView最后一行的空白行,删除空白行
//不显示出dataGridView1的最后一行空白 dataGridView1.AllowUserToAddRows = false; 直接在LODE事件
- intellij idea 解决2019年4月到期延期问题
56ZS5PQ1RF-eyJsaWNlbnNlSWQiOiI1NlpTNVBRMVJGIiwibGljZW5zZWVOYW1lIjoi5q2j54mI5o6I5p2DIC4iLCJhc3NpZ25lZ ...
- SpringBoot+Mybatis+Druid批量更新 multi-statement not allow异常
本文链接:https://blog.csdn.net/weixin_43947588/article/details/90109325 注:该文是本博主记录学习之用,没有太多详细的讲解,敬请谅解! ...