Mybatis 的 xml 文件语法错误,启动项目时控制台一直循环解析但是不打印错误
重写SqlSessionFactoryBean的buildSqlSessionFactory方法:
eg:
package com.slp; import java.io.IOException; import org.apache.ibatis.executor.ErrorContext;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.core.NestedIOException; public class SecureSqlSessionFactoryBean extends SqlSessionFactoryBean {
@Override
protected SqlSessionFactory buildSqlSessionFactory() throws IOException {
try {
return super.buildSqlSessionFactory();
} catch (NestedIOException e) {
e.printStackTrace(); // XML 有错误时打印异常。
throw new NestedIOException("Failed to parse mapping resource: '" , e);
} finally {
ErrorContext.instance().reset();
}
} }
然后在mybatis配置文件中使用重写的类代替SqlSessionFactoryBean即可。
Mybatis 的 xml 文件语法错误,启动项目时控制台一直循环解析但是不打印错误的更多相关文章
- Mybatis映射.xml文件报错
MyBatis框架里面,在dao层进行测试,控制台显示错误是:必须为元素类型 "delete" 声明属性 "resultType" 相应的.xml文件的sql语 ...
- MyBatis Mapper.xml文件中 $和#的区别
MyBatis Mapper.xml文件中 $和#的区别 网上有很多,总之,简略的写一下,作为备忘.例子中假设参数名为 paramName,类型为 VARCHAR . 1.优先使用#{paramN ...
- Mybatis特殊字符处理,Mybatis中xml文件特殊字符的处理
Mybatis特殊字符处理,Mybatis中xml文件特殊字符的处理 >>>>>>>>>>>>>>>>& ...
- mybatis mapper xml文件的导入方式和查询方式
mybatis mapper xml文件的导入方式和查询方式 ssm框架 Mybatis mapper与SQLSession的关系 每个基于MyBatis的应用都是以一个SqlSessionFact ...
- mybatis mapper xml文件配置resultmap时,id行和result行有什么区别?
mybatis mapper xml文件配置resultmap时,id行和result行有什么区别? <resultMap id = "CashInvoiceMap" typ ...
- mybatis的xml文件中的CDATA的使用
mybatis的xml文件中的CDATA的使用 <!--查询列表--> <select id="queryListPage" parameterType=&quo ...
- idea的mybatis的xml文件总是报警告SQL dialect is not configured
警告: No data sources are configured to run this SQL and provide advanced code assistance. Disable thi ...
- java spring 等启动项目时的异常 或 程序异常的解决思路
今天搭建ssm项目的时候,因为pagehelper的一个jar包没有导入idea的web项目下的lib目录中,异常报错找不到pagehelper,这个问题在出异常的时候疯狂crash,让人心情十分不舒 ...
- SpringBoot启动项目时提示:Error:(3, 32) java: 程序包org.springframework.boot不存在
场景 在IDEA中新建SpringBoot项目,后启动项目时提示: Error:(3, 32) java: 程序包org.springframework.boot不存在 实现 将pom.xml中par ...
随机推荐
- PHP7通过yum源安装及性能测试
提到PHP,肯定会有人说这是世界上最好的编程语言.单说流行程度,目前全球超过81.7%的服务器后端都采用了PHP语言,它驱动着全球超过2亿多个网站.上月初PHP7正式版发布,迎来自2004年以来最大的 ...
- IDEA下使用Maven的test命令乱码
IDEA下使用Maven的test命令乱码的时候,加上 -Dfile.encoding=GBK 就可以解决啦 如下图所示: 或者在Maven的pom.xml文件中增加: <propert ...
- android 异常:ScrollView can host only one direct child
android 采用ScrollView布局时出现异常:ScrollView can host only one direct child. 主要是ScrollView内部只能有一个子元素,即不能并列 ...
- 最新整合maven+SSM+Tomcat 实现注册登录
mybatis学习 http://www.mybatis.org/mybatis-3/zh/index.html Spring学习:http://blog.csdn.net/king1425/arti ...
- [kubernetes]helm安装
下载 HELM_VERSION=${K8S_VERSION:-"2.11.0"} HELM="helm-v${HELM_VERSION}-linux-amd64" ...
- 内核编译之vmlinuz vmlinux system.map initrd
一.vmlinuz vmlinuz是可引导的.压缩的内核.“vm”代表“Virtual Memory”.Linux 支持虚拟内存,不像老的操作系统比如DOS有640KB内存的限制.Linux能够使用 ...
- Ubuntu菜鸟入门(十八)————解决Ubuntu下Sublime Text 3无法输入中文
一.下载我们需要的文件,打开终端,输入: git clone https://github.com/lyfeyaj/sublime-text-imfix.git 二.将subl移动到/usr/bin/ ...
- 利用 Express 托管静态文件
通过 Express 内置的 express.static 可以方便地托管静态文件,例如图片.CSS.JavaScript 文件等. 将静态资源文件所在的目录作为参数传递给 express.stati ...
- git代码统计
1.统计一段时间的代码量 git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; gi ...
- 2.Swift快速浏览
传统认为,在一个新的语言的第一个程序要在屏幕上显示“Hello world!”.在Swift,可以用一行代码来完成: println("Hello, world!") 如果你已经在 ...