xml中1字节的UTF-8序列的字节1无效([字符编码]Invalid byte 1 of 1-by

今天在eclipse中编写pom.xml文件时,注释中的中文被eclipse识别到错误:Invalid byte 1 of 1-byte UTF-8 sequence,曾屡次遇到该问题,问题的根源是:eclipse

The cause of this is a file that is not UTF-8 is being parsed as UTF-8. It is likely that the parser is encountering a byte value in the range FE-FF. These values are invalid in the UTF-8 encoding.this

但此次很诡异,我使用notepad++将pom.xml的编码保存为“UTF-8无BOM”形式,pom.xml文件内的encoding属性设置为“UTF-8”,问题依旧啊,郁闷了,难道上述的理论有问题?仍是eclipse的bug呢?在网上看了半天,基本都是这么说的。编码

第一,能够直接在XML文件中更改UTF-8为GBK或GB2312spa

         <?xml   version="1.0"   encoding="GB2312"?> 
code

第二,能够在Eclipse中更改,在 eclipse 的功能表 [Project]→[Properties],點選 [Resources],在右邊的「Text file encoding」,把原來是系統預設的編碼,改為 「UTF-8」。orm

第一种方案可行,属于逃避的方法,放弃!第二种也不是解决我这种问题的,继续网上搜索惊奇的发现,原来解决方案是这样的:xml

把xml的encoding属性值UTF-8改成UTF8,我操,太伤蛋了ip

相关文章
相关标签/搜索