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 ...
随机推荐
- bitnami_redmine3.3.0-1 问题及备份恢复
1. 服务不见了处理方法: 安装Bitnami Redmine之后,会生成5个与之相关的进程,分别是 redmineApache redmineMySQL redmineSubversion redm ...
- JNI C反射调用java方法
前面记录了调用C的学习笔记,现在来记录一下C反射调用Java的笔记.JNI开发学习之调用C方法 Android开发中调用一个类中没有公开的方法,可以进行反射调用,而JNI开发中C调用java的方法也是 ...
- (后端)spring的@Transactional注解详细用法(转)
转自一人浅醉-博客园: 事务隔离级别 隔离级别是指若干个并发的事务之间的隔离程度.TransactionDefinition 接口中定义了五个表示隔离级别的常量: TransactionDefinit ...
- struts2从认识到细化了解
目录 Struts2的介绍与执行流程 介绍: 执行流程: 运行环境搭建 基础示例 Action类的编写 介绍: 访问servlet API 补充: 配置文件 常见配置文件: 常量的配置: struts ...
- Java:字节流和字符流(输入流和输出流)
本文内容: 什么是流 字节流 字符流 首发日期:2018-07-24 什么是流 流是个抽象的概念,是对输入输出设备的抽象,输入流可以看作一个输入通道,输出流可以看作一个输出通道. 输入流是相对程序而言 ...
- 方法调用 Controller的Action 参数
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 在Django中接收文件并存储
首先是一个views函数的例子 def get_user_profiles(request): if request.method == 'POST': myFile = request.FILES. ...
- CVE-2017-8464 分析
目录 CVE-2017-8464(stuxnet 3.0) 分析 0xFF 前言 0x00 分析工具 0x01 漏洞复现 1).生成一个DLL用于测试 2).构造一个恶意的lnk二进制文件 3).RU ...
- Vue学习之路5-v-model指令
1. 指令释义 v-model在表单控件或者组件上创建双向绑定,本质上是负责监听用户的输入事件(onchange,onkeyup,onkeydown等,具体是哪个,还请查阅官方底层实现文档)以更新数据 ...
- main主函数
public static void main(String[] args) { //虚拟机调用main函数,需要传个args的参数,传入的是new String[0] System.out.prin ...