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 ...
随机推荐
- linux 启动 Oracle 实例
启动数据库实例,分为两步:第一步,启动监听:第二步,启动数据库实例. 一.如何启动数据库实例 1.进入到sqlplus启动实例 --“切换到oracle用户” su - oracle --“打开监听” ...
- Dictionary简洁
mydic_ShuiFei = new Dictionary<string, string>() { {"00000336","南京市 ...
- LeetCode Permutations问题详解
题目一 permutations 题目描述 Given a collection of numbers, return all possible permutations. For example,[ ...
- Hadoop2.2.0分布式安装配置详解[3/3]
测试启动 按照下面的每一步执行,执行完一定要看输出的信息,注意warn或error或fatal的情况.因为这都是可能是问题出现的地方.出现一个问题,不解决,可能就会影响接下来的测试.这才是真正的工作量 ...
- 基于Centos搭建 Mono 开发环境
系统要求: CentOS 7.2 64 位操作系统 安装 Mono 安装前的准备 yum install yum-utils 执行命令添加安装包仓库 rpm --import "http:/ ...
- Docker linux安装
Ubuntu下安装 sudo wget -qO- https://get.docker.com/ | shsudo usermod -aG docker imooc Centos7下安装 CentO ...
- 【CLR】详解CLR中的程序集
目录结构: contents structure [+] 程序集的简介 为程序集分配强名称 如何指定程序集的版本资源信息 如何对程序集签名 全局程序集缓存 如何查看程序集的信息 强命名程序集防串改 1 ...
- 各个屏幕的logo尺寸要求
DENSITY SIZE LOCATION RATIO SCREEN MARGIN XXXHDPI 192×192 drawable-xxxhdpi 4 640 DPI 12 to 16 pixels ...
- 0x01 Spring Cloud 概述
Spring Cloud Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线,一次性令牌,全局锁定,领导选举,分 ...
- Atitit 常用sdk 模块 组织架构切分 规范与范例attilax总结
Atitit 常用sdk 模块 组织架构切分 规范与范例attilax总结 常用200个模块 2017/04/12 22:01 <DIR> acc 2017/04 ...