The string "--" is not permitted within comments.问题解决

前端之家收集整理的这篇文章主要介绍了The string "--" is not permitted within comments.问题解决前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今天写ssm整合时发现,使用jdk1.8时,xml解析是正常的,但是项目环境切换到jdk1.6时,报错:

org.mybatis.generator.exception.XMLParserException: XML Parser Error on line 22: The string "--" is not permitted within comments.
    at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:111)
    at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:82)
    at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:74)
    at com.leige.test.MybatisGen.generator(MybatisGen.java:20)
    at com.leige.test.MybatisGen.main(MybatisGen.java:27)

可能是高版本的jdk对于xml解析已经考虑到字符编码的问题,
最后发现,将项目的字符编码,改为utf-8就可以正确解析

其他人的解决办法:

1. 这个问题之前看到过有一种解决方案,就是在注释结束前,也就是“–>”前面加一个英文半角的空格。
2. 今天发现了另外一个解决方法,就是执行程序的时候加上jvm的参数
-Dfile.encoding=UTF8
这样子就算注释结束符前面不加空格也是可以的。
用eclipse的可以在run或者debug configuration里面添加vm参数。


org.xml.sax.SAXParseException
XML解析异常
由于xml中<!-- 【注释】--> 注释与-->之间没有空格造成xml解析错误
原文链接:https://www.f2er.com/xml/295275.html

猜你在找的XML相关文章