org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may
来源:互联网 发布:windows hosts文件位置 编辑:程序博客网 时间:2024/05/16 09:06
跟着mybatis官方文档再次学习mybatis,果然,还是不记得一些配置了…
同时,官方文档也是坑小白哦
官方文档中文 http://www.mybatis.org/mybatis-3/zh/getting-started.html
在使用xml配置文件进行sqlsession获取的时候出现以下报错
org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### The error may exist in com/wy/bean/StudentMapper.xml### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Student'. Cause: java.lang.ClassNotFoundException: Cannot find class: Student
看报错提示很明显知道是Student这个类找不到,同时提示了可能发生错误的地方是
The error may exist in com/wy/bean/StudentMapper.xml
以下是我的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.wy.bean.StudentMapper"> <!-- 查找所有学生 --> <select id="selectAllStudent" resultType="Student" > select * from student </select></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="org.mybatis.example.BlogMapper"> <select id="selectBlog" resultType="Blog"> select * from Blog where id = #{id} </select></mapper>
仔细看resultType那块!直接是一个类名,然而在mybatis-config.xml中也没有配置类别名的相关配置,SO,被文档坑了…
解决方案
在mybatis-config.xml没有配置类别名的时候需要写上类的全路径
<?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.wy.bean.StudentMapper"> <!-- 查找所有学生 --> <!-- 注意:在mybatis-config.xml没有配置类别名的时候需要写上类的全路径 --> <select id="selectAllStudent" resultType="com.wy.bean.Student" > select * from student </select></mapper>
阅读全文
0 0
- org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may
- org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may
- org.apache.ibatis.exceptions.PersistenceException: Error building SqlSession
- MyException--org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ###
- org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### Cause: org.ap
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.
- org.apache.ibatis.exceptions.PersistenceException:
- org.apache.ibatis.exceptions.PersistenceException
- org.apache.ibatis.exceptions.PersistenceException
- org.apache.ibatis.exceptions.PersistenceException
- 遇到org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.
- mybatis报错Error building SqlSession. ### Cause: org.apache.ibatis.builder.BuilderException: Error cre
- org.apache.ibatis.exceptions.PersistenceException: 问题
- MyBatis org.apache.ibatis.exceptions.PersistenceException NoSuchMethodException
- org.apache.ibatis.exceptions.PersistenceException:解决方法
- Mybatis-org.apache.ibatis.exceptions.PersistenceException
- 异常:org.apache.ibatis.exceptions.PersistenceException:
- org.apache.ibatis.exceptions.PersistenceException: 的解决
- 数据结构实验之图论五:从起始点到目标点的最短步数(BFS)
- [Python]网络爬虫:利用urllib2通过指定的URL抓取网页内容
- 收集箱子
- ubuntu 16.04 LTS
- 阿里开发规范--笔记(二)
- org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may
- UI5编程 – 注册service到SAP gateway server
- 欢迎使用CSDN-markdown编辑器
- DBUtils和连接池
- Ubuntu ORTP 编译及安装
- 训练集,验证集和测试集
- 实验一 网线的制作--自我操作
- 实例:SSH结合Easyui实现Datagrid的新增功能和Validatebox的验证功能.
- “戏”说spark---资源调度和任务调度