今天在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