[ERROR] /D:/IDEA文件/travel/src/main/java/cn/itcast/travel/util/MailUtils.java:[1,1] 非法字符: '\ufeff'...

本文详细解析了一个Maven编译失败的问题,错误源自Java源文件的编码格式不匹配,具体表现为非法字符'ufeff'。通过使用Notepad++检查并更正MailUtils.java文件的编码从utf-8-bom到utf-8,成功解决了编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错:

[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并保存:

 

 

问题解决。

转载于:https://www.cnblogs.com/bloggary/p/11506684.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值