---
title: "Ibatis XML 配置文件注释引起错误及解决方案"
author: "grefr"
date: "2013-05-30T15:21:11Z"
tags: []
categories: ["开源软件"]
slug: "ibatis-xml"
draft: false
lastmod: "2015-06-16T17:34:07Z"
id: 1880004
url: "https://grefr.iteye.com/blog/1880004"
---

详见：<http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp35>

Ibatis XML 配置文件注释引起错误及解决方案
最近在使用Ibatis组件进行一个项目开发，在运行时发现提示如下错误信息：
type 异常报告
消息
描述服务器遇到一个内部错误 (), 无法完成此请求。
异常
javax.servlet.ServletException: java.lang.ExceptionInInitializerError根本原因
java.lang.ExceptionInInitializerError根本原因
java.lang.RuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.根本原因
com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.根本原因
java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.根本原因
com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.根本原因
org.xml.sax.SAXParseException: The string "--" is not permitted within comments.

－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－
从错误描述来看发现是ＸＭＬ文件中的注释引起的异常，去掉配置文件中的中文注释或改用英文描述则可以通过
后来发现是配置文件中采用：单数个中文或字母后跟单数个中文再用“-->”结束注释（中文后不加空格）
如：<!-- 单数个中文-->、<!-- a单数个中文-->
时就会报此异常
争对此异常可以采用在左右边界加上空格的方式解决。 如像这样是对的 <!--   中文注解    -->