报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project travel: Compilation failure: Compilation failure: [ERROR] /D:/IDEA文件/travel/src/main/java/cn/itcast/travel/util/MailUtils.java:[1,1] 非法字符: '\ufeff' [ERROR] /D:/IDEA文件/travel/src/main/java/cn/itcast/travel/util/MailUtils.java:[1,10] 需要class, interface或enum [ERROR] -> Help 1 [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 For more information about the errors and possible solutions, please read the following articles:
jdk 的pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
判断:
该文件 D:/IDEA文件/travel/src/main/java/cn/itcast/travel/util/MailUtils.java 的编码错误。
处理:
用notepad++打开MailUtils.java文件,查看编码发现:


编码为utf-8-bom。用notepad++修改编码为utf-8并保存:


问题解决。