ibatis错误汇总
1) 错误:The prefix "context" for element "context:property-placeholder" is not bound.
解决:在文件头中引入:xmlns:context="http://www.springframework.org/schema/context" 就可以。
正解样例:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName">
<context:property-placeholder location="classpath:META-INF/app.properties" />
2) 错误:Cannot convert value of type [org.springframework.jdbc.datasource.DriverManagerDataSource] to required type [com.ibatis.sqlmap.client.SqlMapClient] for property 'sqlMapClient': no matching editors or conversion strategy found
原因:property sqlMapClient 引错了id;一開始ref的不是baikeZhangzishiSqlMapClientReadonly,而是baikeZhangzishiDataSourceReadonly
正解:
<bean id="baikeZhangzishiReadTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate" destroy-method="close">
<property name="sqlMapClient"><ref bean="baikeZhangzishiSqlMapClientReadonly" /></property>
</bean>
<bean id="baikeZhangzishiDataSourceReadonly" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/mysqlAppsDataSourceReadonly</value>
</property>
</bean>
<bean id="baikeZhangzishiSqlMapClientReadonly" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:/ibatis/baikeZhangzishi-sqlmap.xml</value>
</property>
<property name="dataSource" ref="baikeZhangzishiDataSourceReadonly"></property>
</bean>
3)有例如以下两个错误:
错误1:com.ibatis.sqlmap.client.SqlMapException: There is no statement named MS-APPBAIKEZHANGZISHI-ADDINFO in this SqlMap.
错误2:java.lang.NullPointerException
at com.hudong.apps.baikesurvey.dao.impl.BaikeZhangzishiWriteDAOImpl.addBaikeZhangzishi(BaikeZhangzishiWriteDAOImpl.java:29)
at com.hudong.apps.baikesurvey.dao.test.BaikeZhangzishiDAOTest.testAdd(BaikeZhangzishiDAOTest.java:81)
at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163)
分析:从表面上看,这两个错误系属一个错误,都是sqlMap找不到,可能是相关的xml配置找不到,也可能是id错误,也可能是set注入错误;
我犯得错误是set注入错误,所以在做一些底层东西copy的时候一定要注意这些细节,看看id有没有负责后忘了更改,从而导致set注入相关的spring id,还应该注意的是假设原project使用了高度封装,比方创建一个basedao 存放一些set注入等信息的时候,这时候copy的东西一定要去这个base类中加入对应的模块,比方set注入模块
4)1ibatis错误
com.ibatis.sqlmap.client.SqlMapException: There is no statement named MS-QUERY-TOP-PAGE in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:231)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:558)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
错误分析:ibatis+spring+jndi+resin使用的使用一定要注意一些配置上面的细节;我这里所犯的错误是由于ibatis配置引用底层sqlxml的时候没有放到sqlMapConfig中;注意jndi的配置不能直接引用ibatis的底层sql文件,必须引用有sqlMapConfig配置的xml文件;
错误例如以下:
jndi 直接引用sql的xml;
<!-- dataSource readonly -->
......
<bean id="topSqlMapClientReadonly" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:/ibatis/com/hudong/apps/baikesurvey/sqlmap/top1000-readonly-sqlmap-mapping.xml</value>
</property>
<property name="dataSource" ref="topDataSourceReadonly"></property>
</bean>
......
正确使用:
<!-- dataSource readonly -->
<bean id="topDataSourceReadonly" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/mysqlDataSourceReadonly</value>
</property>
</bean>
<bean id="topSqlMapClientReadonly" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:/ibatis/baikeSurvey-sqlmap.xml</value>
</property>
<property name="dataSource" ref="topDataSourceReadonly"></property>
</bean>
<bean id="topReadTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate" destroy-method="close">
<property name="sqlMapClient"><ref bean="topSqlMapClientReadonly"/></property>
</bean>
注意ibatis的sqlmap配置,一定要放入sqlMapConfig中;这里另一点要注意的,那就是useStatementNamespaces命名空间的配置,这里假设设置成了false,那么底层sql配置文件就能够不配置命名空间;假设设置成了true,那么必须配置命名空间,否则也会出现这个错误
<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true" enhancementEnabled="false" lazyLoadingEnabled="false" maxRequests="3000" maxSessions="3000" maxTransactions="3000" useStatementNamespaces="false"/>
<sqlMap resource="ibatis/com/hudong/apps/baikesurvey/sqlmap/top1000-readonly-sqlmap-mapping.xml"/>
</sqlMapConfig>
命名空间的配置,注意多个sql xml命名空间不能反复;例如以下:
<sqlMap namespace="topReadSqlMap">
未完待续
ibatis错误汇总的更多相关文章
- Entity Framework学习笔记——错误汇总
之前的小项目做完了,到了总结经验和更新学习笔记的时间了.开始正题之前先啰嗦一下,对之前的学习目标进行一个调整:“根据代码生成表”与“生成数据库脚本和变更脚本”合并为“Code First模式日常使用篇 ...
- 李洪强iOS开发之OC常见错误汇总
// // main.m // 16 - 常见错误汇总 // // Created by vic fan on 16/7/13. // Copyright © 2016年 李洪强. All r ...
- Python常见的错误汇总
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 错误: [错误分析]第二个参数必须为类,否则会报TypeError,所以正确的应 ...
- PHP常见错误汇总
日常开发和调试的时候,经常会遇到一些错误,光怪陆离的不知所以,所以,特此将错误汇总一下,借鉴!!! 1. 原因分析: 一般可能是该文件出现了问题,检查一下代码和格式,是否出现开始的地方出现了空格,或 ...
- Quartus II 中 Verilog 常见警告/错误汇总
Verilog 常见错误汇总 1.Found clock-sensitive change during active clock edge at time <time> on regis ...
- android studio 错误汇总以及解决办法
android studio 错误汇总以及解决办法 参考 https://www.jianshu.com/p/7c7de6562231 问题1. Error:Execution failed for ...
- 编程中易犯错误汇总:一个综合案例.md
# 11编程中易犯错误汇总:一个综合案例 在上一篇文章中,我们学习了如何区分好的代码与坏的代码,如何写好代码.所谓光说不练假把式,在这篇文章中,我们就做一件事——一起来写代码.首先,我会先列出问题,然 ...
- react 报红错误汇总
react 报红错误汇总 一.Uncaught TypeError: Cannot read property 'value' of undefined 未知类型错:无法读取未定义的属性“value ...
- Jmeter工具做性能测试 常见的错误汇总
在Win机器上用Jmeter做性能测试,汇总下我自身遇到的错误和解决方案 java.net.BindException: Address already in use: JVM_Bind 原因分析:压 ...
随机推荐
- Kafka测试
准备工作 硬件:笔记本,windows10系统4核8G内存 软件:接口测试工具,以及kafka自带测试工具 影响测试结果配置分析 Borker num.network.thread=3 用于接收并处理 ...
- android CMWAP, CMNET有何差别
什么是CMNET,什么是CMWAP? 答:CMWAP和CMNET仅仅是中国移动为其划分的两个GPRS接入方式.中国移动对CMWAP作了一定的限制,主要表如今CMWAP接入时仅仅能訪问GPRS网络内的I ...
- iOS开发之让你的应用“动”起来
概览在 iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌.在这里你可以看到iOS中如何使用图层精简非交互 式绘图,如何通过核心动画创建基础动画.关键帧动 ...
- js获取名字为XX的标签
$("input[name='XX']"); <input name="address_select" type="radio" va ...
- RMAN-FORMAT-CONFIGURE及动态性能表
一.FORMAT参数在备份过程中,可指定format参数来自定义备份片段的命令规则,比如: RMAN> BACKUP DATABASE FORMAT 'D:\BACKUP\%U'; RMAN&g ...
- 前端判断用户请求是PC还是移动端
链接:https://www.zhihu.com/question/20004700/answer/13678113 第一步先在服务器端使用User Agent判断,先匹配出移动设备,这一步可以统计U ...
- 使用图片拉伸resizableImageWithCapInsets
在仿写QQ会话的时候背景蓝色图片是拉伸而来,但是有些地方是受保护的不能拉伸 所以定义了下面的工具类中的一个方法,专门拉伸图片 UIImageResizingModeStretch:拉伸模式,通过拉伸U ...
- VS2015预览版中的C#6.0 新功能(一)
VS2015预览版中的C#6.0 新功能(二) VS2015预览版中的C#6.0 新功能(三) VS2015的预览版在11月12日发布了,下面让我们来看看C#都提供了哪些新的功能. 字符串添写(Str ...
- C#线程池ThreadPool的理解
在多线程编程中,线程的创建和销毁是非常消耗系统资源的,因此,C#引入了池的概念,类似的还有数据库连接池,这样,维护一个池,池内维护的一些线程,需要的时候从池中取出来,不需要的时候放回去,这样就避免了重 ...
- uva 10391 Compound Words <set>
Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound ...