打包maven項目的時候,出現異常:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.303s [INFO] Finished at: Fri Sep 09 12:57:08 CST 2016 [INFO] Final Memory: 11M/150M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project common-test-webapp: Compilation failure: Compilation failure: [ERROR] H:\dev\source\workspace\common-test-webapp\src\main\java\com\test\util\GetPy.java:[1,0] 錯誤: 非法字符: \65279 [ERROR] H:\dev\source\workspace\common-test-webapp\src\main\java\com\test\util\GetPy.java:[1,9] 錯誤: 需要class, interface或enum [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
打開文件H:\dev\source\workspace\common-test-webapp\src\main\java\com\test\util\GetPy.java,發現里面並沒有什么錯誤,在eclipse里也沒有報錯,是什么原因呢?
出現這種錯誤的原因大概有幾種情況:
1、操作系統的原因,操作系統不同,出現了一些不可見字符。
2、某些編輯工具的原因,編輯工具自己默認添加了一些不可見字符。
快速解決方法:備份原有文件后,刪除該文件,重新建立一個空白文件,將原文件內容復制到新文件中即可。