元素类型为 “resultMap“ 的内容必须匹配 “(constructor?,id*,result*,association*,collection*,discriminator?)“ ———————————————— 版权声明:本文为CSDN博主「熊猫大哥大」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/woshisangsang/article/details/79738301

简介: 本文目录1. 现象2. 原因

1. 现象

最近写MyBatis的ResultMap是不小心遇到了如下错误,看着还怪吓人的。

Caused by: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 17; 元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminator?)"。
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
  at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:254)
  ... 46 more

2. 原因

由于英语水平比较坑,一时没反应过来,后来发现是resultMap元素中,<id>、<result>、<assoation>都是有顺序的,我不小心把一个assocation元素放在了result中间导致这一个异常。


另外提下,MyBatis中xml配置好像都是有顺序的,看到类似元素类型XXX的内容必须匹配(XXX),应该都是类似的错误。

相关文章
|
C++
【C/C++ 编程 入门篇】 if条件判断表达式的使用教程
https://developer.aliyun.com/article/1465430
837 0
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
这篇文章是关于计算机组成原理的王道考研学习笔记,主要介绍了半导体存储器RAM和ROM的相关知识。
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
|
算法 Java 测试技术
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
2703 1
|
监控 Shell 开发工具
https://developer.aliyun.com/article/1583352
https://developer.aliyun.com/article/1583352
|
存储 PyTorch 调度
https://developer.aliyun.com/article/1564927(7)
Transformers 4.37 中文文档(十九)
654 2
|
Java Unix Linux
https://developer.aliyun.com/article/1495767
https://developer.aliyun.com/article/1495767
335 1
|
存储 Ubuntu Linux
https://blog.csdn.net/a1657054242/article/details/139965955?spm=1001.2014.3001.5502
https://blog.csdn.net/a1657054242/article/details/139965955?spm=1001.2014.3001.5502
568 0
针对持续不断的产品市场制造商的自动攻击合成 https://developer.aliyun.com/article/1512648?spm=a2c6h.13262185.profile.22.7e32b28arRWTOH T恤或卫衣 针对持续不断的产品市场制造商的自动攻击合成 针对持续不断的产品市场制造商的自动攻击合成
针对持续不断的产品市场制造商的自动攻击合成 https://developer.aliyun.com/article/1512648?spm=a2c6h.13262185.profile.22.7e32b28arRWTOH T恤或卫衣 针对持续不断的产品市场制造商的自动攻击合成 针对持续不断的产品市场制造商的自动攻击合成
361 0
|
JSON 前端开发 数据格式
https://tigerhhzz.blog.csdn.net/article/details/129961946?spm=1001.2014.3001.5502
https://tigerhhzz.blog.csdn.net/article/details/129961946?spm=1001.2014.3001.5502
338 0
|
安全 网络协议 Linux
Linux网络应用层协议展示:HTTP与HTTPS
此外,必须注意,从HTTP迁移到HTTPS是一项重要且必要的任务,因为这不仅关乎用户信息的安全,也有利于你的网站评级和粉丝的信心。在网络世界中,信息的安全就是一切,选择HTTPS,让您的网站更加安全,使您的用户满意,也使您感到满意。
624 19