首页

解决运行mybatis-generator生成类报org.mybatis.generator.exception.XMLParserException异常问题

标签:XMLParserException,异常,SAXParseException,mybatis-generator     发布时间:2017-10-14   

一、异常描述

eclipse中通过mybatis-generator生成dao、mappers及model代码时(步骤参考“通过mybatis-generator-core工具自...”页面),报出“org.mybatis.generator.exception.XMLParserException”异常,通过关联源码包(mybatis-generator-core-1.3.4-sources.jar),跟踪代码详细异常是“org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xd8fb) was found in the element content of the document.”,明细错误日志如下

org.mybatis.generator.exception.XMLParserException@b@	at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:111)@b@	at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:82)@b@	at org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration(ConfigurationParser.java:74)@b@	at com.xwood.gen.GeneratorExecuter.generator(GeneratorExecuter.java:20)@b@	at com.xwood.gen.GeneratorExecuter.main(GeneratorExecuter.java:29)@b@	@b@	@b@	org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xd8fb) was found in the element content of the document.

二、解决方法

1.当报“XMLParserException”异常时,通过如下关联源码,进行下一步调试跟踪

解决运行mybatis-generator生成类报org.mybatis.generator.exception.XMLParserException异常问题

2.关联源码111行,查看SAXParseExcepion异常信息“org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xd8fb) was found in the element content of the document”

解决运行mybatis-generator生成类报org.mybatis.generator.exception.XMLParserException异常问题

3.根据步骤2,可以判断generator.xml中有特殊字符引起的,结果发现注释中有个中文“,”引起,换成英文“,”问题解决了