ibatis项目启动报错The string "--" is not permitted within comments【原】

该错误主要就是因为xml中<!-- 【注释】--> 注释与-->之间没有空格造成xml解析错误

sqlMapConfig.xml内容如下

<?xml version="1.0" encoding="UTF-8"?>
<!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="true" lazyLoadingEnabled="true" errorTracingEnabled="true" maxRequests="100" maxSessions="100" maxTransactions="100" useStatementNamespaces="true"/>  

  <!-- 老师 -->
  <sqlMap resource="com/test/edu/sqlmap/sqlmap-teacher.xml"/>

  <!-- 学生 -->
  <sqlMap resource="com/test/edu/sqlmap/sqlmap-student.xml"/>
</sqlMapConfig>

而sqlmap-student.xml内容如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
        "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap>
    <!-- 统计学生-->
    <select id="countStudent" parameterClass="com.test.edu.Student"
        resultClass="com.test.edu.Student">
        select * from tbl_student where id = '1';
    </select>
</sqlMap>

问题就出在"统计学生"附近 , 仔细看会发现统计学生和-->之间没有空格。

原文地址:https://www.cnblogs.com/whatlonelytear/p/9323182.html