Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException奇葩解决方案
项目场景:
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/bjsxt/mapper/UserMapper.xml
问题描述:
在使用mybatis框架,通过id查询用户时,出现异常;
</select>
<!-- 根据用户id查询用户 参数类型可以不写--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">/* #{}相当于jdbc中的问号,直接在{}中给定绑定参数的名称;如参数只有一个叫什么都可以,但要是有多个就需要具体参数名称了;*/select * from users where userid = #{suibian}</select>
原因分析:
这样的异常:是映射文件出现了错误,大多数都是resultType的配置出现了错误,但是今天我这个错误优点奇葩;
解决方案:
将代码中的注释删掉就解决了;
异常代码
</select>
<!-- 根据用户id查询用户 参数类型可以不写--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">/* #{}相当于jdbc中的问号,直接在{}中给定绑定参数的名称;如参数只有一个叫什么都可以,但要是有多个就需要具体参数名称了;*/select * from users where userid = #{suibian}</select>
消除异常后代码:
</select>
<!-- 根据用户id查询用户 参数类型可以不写--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">select * from users where userid = #{suibian}</select>
解决后我也是无语了;
在这里再加一句,不论是/* */注释,还是选中Ctrl+/注释都是会报相同的异常的;
在这里建议就不要加注释了,如果真的要加还是放到select标签外面吧!
Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException奇葩解决方案相关推荐
- Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException:报错解决
进行MyBatis连接数据库遇到这个异常: 报错代码: Exception in thread "main" org.apache.ibatis.exceptions.Persis ...
- Exception in thread “main“ org.apache.ibatis.binding.BindingException: Invalid bound statement (not
IDEA报错–mybatis Exception in thread "main" org.apache.ibatis.binding.BindingException: Inva ...
- Exception in thread “main“ org.apache.ibatis.binding.BindingException: Type interface com.neusoft.Id
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com. ...
- 报错:Exception in thread “main“ org.apache.ibatis.binding.BindingException: Invalid bound statement (n
建立Spring+SpringMVC+JDBC项目报以下错误: 解决办法: 在pom.xml的bulid标签里面加上如下代码: <resources><resource>< ...
- Exception in thread “main“ org.apache.hadoop.hbase.client.RetriesExhaustedException: Can‘t get the l
看尚硅谷视频,在windows上运行集群上的hbase时 package org.example;import org.apache.hadoop.hbase.HBaseConfiguration; ...
- 解决Exception in thread “main“ org.apache.spark.SparkException: When running with master ‘yarn‘ either
Exception in thread "main" org.apache.spark.SparkException: When running with master 'yarn ...
- Exception in thread main org.apache.thrift.transport.TTransportException: Could not create ServerS
Exception in thread "main" org.apache.thrift.transport.TTransportException: Could not crea ...
- Exception in thread “main“ org.apache.http.conn.ConnectTimeoutException: Connect to 134.00.00.00:00
Exception in thread "main" org.apache.http.conn.ConnectTimeoutException: Connect to 134.00 ...
- 已解决idea连接数据库异常:Exception in thread “main“ com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You ...
最新文章
- 二十八、动态分区分配算法
- IntelliJ IDEA Community 社区版配置 Web 开发环境(Gradle + Tomcat)
- 无法找到脚本文件adsutil.vbs的解决方法
- 软件体系结构C2风格
- 清除word中超链接
- linux c的连接库和怎么同时编译多个源程序
- 51CTO大数据学习006--集合
- scrapy爬虫循环抓取同一个url,避免同一URL使爬虫关闭
- js数字比较【牢记】
- 【威佐夫博奕】 betty定理 poj 1067
- 软件测试必须知道的精华总结
- onpropertychange
- Java工作流引擎学习----JBPM(一)
- 禅道linux客户端服务端,禅道11.0版本发布,主要集成禅道客户端
- 【华为OD机试真题 JAVA】事件推送
- 计算机网络面试题汇总
- 域名虚拟主机_域名和虚拟主机之间有什么区别(解释)
- matlab遗传算法外卖配送优化(新的约束条件)【matlab优化算法十六】
- the win16 subsystem was unable to enter protected mode,DOSX.EXE must be in your AUTOEXEC.NT and pres
- 【VUE-编辑回显】
热门文章
- 29-分数求模(逆元)
- 无向图的完美消除序列 判断弦图 ZOJ 1015 Fish net
- ACM中java的使用 (转)
- FCKeditor 2.6.4.1 初始化值不能显示中文问题
- eclipse 安装jetty时遇到的问题
- HDU1020 Encoding
- 《YES!B/S!》博客文章导读索引(20080612更新)
- Linux SPI总线和设备驱动架构之三:SPI控制器驱动
- 线程共享的环境包括:进程代码段、进程的公有数据(利用这些共享的数据,线程很容易的实现相互之间的通讯)、进程打开的文件描述符、信号的处理器、进程的当前目录和进程用户ID与进程组ID。 进程拥有这
- Hyperledger Fabric 核心模块(2)configtxgen configtx.yaml配置文件