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>

 

問題就出在"統計學生"附近 , 仔細看會發現統計學生和-->之間沒有空格。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM