Attribute "resultType" must be declared for element type "insert"或"update"
Attribute "resultType" must be declared for element type "insert"或"update"
今天写代码的时候,写mybatis的update语句和insert语句,写完之后,开jetty,但是很久过去,jetty卡卡住不动,
[logistics] 2016-02-01 16:40:54 577 main com.alibaba.druid.filter.logging.Log4jFilter.connectionLog(Log4jFilter.java:132)
[DEBUG] {conn-10010} setAutoCommit false这个问题一般是xmL中有错误导致的,但是查看了很久,都没与发现,知道jetty运行超时,报错。看到报错日志。如下图:
这个报错日志中说Attribute "resultType" must be declared for element type "insert",还有一个报错信息是Attribute "resultType" must be declared for element type "update"
当时一直没有找到那里有问题,一直以为问题是我写insert和update语句是没有写resultType,后来发现,问题恰恰出在此处。
因为在insert和update语句中是没有resultType的,报错的信息不是说没有写resultType,而是说要在mybatis的文件中声明resultType之后,才可以使用resultType.
在xml文件的开头一般有两行代码:
DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"
将http://mybatis.org/dtd/mybatis-3-mapper.dtd复制到浏览器中,会自动下载dtd文件,打开后,搜索update和insert和select,会发现之间的区别:
select的声明如下:
ATTLIST select
id CDATA #REQUIRED
parameterMap CDATA #IMPLIED
parameterType CDATA #IMPLIED
resultMap CDATA #IMPLIED
resultType CDATA #IMPLIED
resultSetType (FORWARD_ONLY | SCROLL_INSENSITIVE | SCROLL_SENSITIVE) #IMPLIED
statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
fetchSize CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
useCache (true|false) #IMPLIED
databaseId CDATA #IMPLIED
lang CDATA #IMPLIED
resultOrdered (true|false) #IMPLIED
resultSets CDATA #IMPLIED
insert的声明如下:
ATTLIST insert
id CDATA #REQUIRED
parameterMap CDATA #IMPLIED
parameterType CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
keyProperty CDATA #IMPLIED
useGeneratedKeys (true|false) #IMPLIED
keyColumn CDATA #IMPLIED
databaseId CDATA #IMPLIED
lang CDATA #IMPLIED
update的声明如下:
ATTLIST update
id CDATA #REQUIRED
parameterMap CDATA #IMPLIED
parameterType CDATA #IMPLIED
timeout CDATA #IMPLIED
flushCache (true|false) #IMPLIED
statementType (STATEMENT|PREPARED|CALLABLE) #IMPLIED
keyProperty CDATA #IMPLIED
useGeneratedKeys (true|false) #IMPLIED
keyColumn CDATA #IMPLIED
databaseId CDATA #IMPLIED
lang CDATA #IMPLIED
可以看出select声明中有resultType,而update和insert中没有resultType
错误在此。
Attribute "resultType" must be declared for element type "insert"或"update"的更多相关文章
- Attribute "resultType" must be declared for element type "insert".
这是mybatis插入数据库之后出现的问题,至于为什么出现这个问题,是因为插入的时候你照抄了查询的语句,插入的时候只有id属性和parameterType属性,并没有“resultType”属性,要注 ...
- Attribute "resultType" must be declared for element type "update" or "insert"
仔细查看错误如图所示: 解决错误就是把resultType去掉,因为在insert和update语句中是没有返回值的.小坑小坑 转自:https://blog.csdn.net/u013144287/ ...
- Multiple annotations found at this line: - The content of element type "mapper" must match "EMPTY". - Attribute "namespace" must be declared for element type "mapper".
今天在mybatis的mapper映射配置文件中遇到了这样的问题,困扰了我3个小时: Multiple annotations found at this line: - The content of ...
- Attribute "not-null" must be declared for element type "property"解决办法
Attribute "not-null" must be declared for element type "property"解决办法 在hiberante ...
- Attribute "resource" must be declared for element type "mapper".
今天在玩mybatis的时候,遇到这个奇葩问题. 最后发现,原因是 dtd文件配置错误了.错把Mapper的直接copy过来 把DOCTYPE mapper改成configuration,Mapper ...
- Attribute name "aphmodel" associated with an element type "mxg" must be followed by the ' = ' charac
1.错误描述 org.apache.batik.transcoder.TranscoderException: null Enclosed Exception: Attribute name &quo ...
- 【resultType】Mybatis种insert或update的resultType问题
Attribute "resultType" must be declared for element type "insert"或"update&q ...
- Open quote is expected for attribute "property" associated with an element type "result".错误
java Mybatis 框架下的项目 报 Open quote is expected for attribute "property" associated with a ...
- [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associated with an element type "id".
用DOM解析XML时出现了如下错误: [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associa ...
随机推荐
- 华为P20无线投屏到电脑 绝地求生投射电脑
如今出门在外,必不可少的就是手机,如果没有了手机,每个人都会感觉没有安全感,感觉和世界失去了联系,我们每天每个人都在使用手机,但是作为华为手机用户的你,了解华为P20无线投屏到电脑是怎么操作的吗? 使 ...
- Android Studio 之 注释模板
我们看有的项目的文档,会发现它的注释写的很好看,很规范. 而如果你的代码注释还是在用简单的 // 或者 /**/ ,那就学习一下在Android Studio中如何进行注释模板的设置 首先看下面代码 ...
- onmouseover和onmouseenter区别
onmouseover和onmouseenter都是鼠标进入时触发,onmouseover在所选元素的子元素间切换的时候也触发! <!doctype html><html lang= ...
- Spark操作HBase报:org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException异常解决方案
一.异常信息 19/03/21 15:01:52 WARN scheduler.TaskSetManager: Lost task 4.0 in stage 21.0 (TID 14640, hnte ...
- SQL中的ALL,ANY,SOME的用法
准备两个表: --T1(2,3)--T2(1,2,3,4) --ALL,ANY,SOME 的子查询-- >ALL 父查询中的结果集大于子查询中每一个结果集中的值,则为真SELECT * FROM ...
- Linux如何查看YUM的安装目录
Linux下如何查看使用YUM安装过的包的安装路径呢? 在搞清楚这个问题前,我们先来了解一下YUM. YUM(全称为 Yellow dog Updater, Modified)是一个在Fedora和R ...
- setfont()函数
设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号); 字体:TimesRoman, Courier, Arial等 风格:三个常量 lFont.P ...
- [20181130]hash冲突导致查询缓慢.txt
[20181130]hash冲突导致查询缓慢.txt --//昨天看了链接https://jonathanlewis.wordpress.com/2018/11/26/shrink-space-2/, ...
- PHP中判断变量是否存在的方式
isset()函数判断变量是否设置. thinkPHP中判断select查询时返回值是否为空 $object->isEmpty() empty():当变量存在,并且是一个非空非零的值时,返回 ...
- Python: 遍历
======================遍历列表========================# 直接遍历list: for elem in list: pass # 通过索引获取 for i ...