打包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、某些编辑工具的原因,编辑工具自己默认添加了一些不可见字符。
快速解决方法:备份原有文件后,删除该文件,重新建立一个空白文件,将原文件内容复制到新文件中即可。