Faild to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)

本文介绍了Maven构建过程中出现的非法字符错误及解决方案,通过检查项目配置和重新构建项目来解决此类问题。

maven构建异常问题

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myhibernate3
[ERROR] /E:/myWorkplace/SSH1/src/main/java/com/iflytek/util/Page.java:[1,1] 非法字符: '\ufeff'
[ERROR] /E:/myWorkplace/SSH1/src/main/java/com/iflytek/util/Page.java:[1,10] 需要class, interfaceenum
[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.

首先检查jdk版本问题,没问题的话 再 右键点击 项目–>Properties–>查看libraries
这里写图片描述
再查看是否添加了maven依赖,Order and Export
这里写图片描述

勾上之后 右键点击项目 –>Build Project (至关重要的一步) 就可以解决问题了

这个问题只能怪自己手贱 把 eclipse 的 Project–>build Automatically给 关闭,勾选了 就不会出先这种问题……

执行 `org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile` 目标失败可能有以下几种原因: - **JDK 版本不兼容**:项目使用的 JDK 版本可能与 `maven-compiler-plugin` 配置的 JDK 版本不一致。例如打包项目时抛出 `Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project springbootdemo: Fatal error compiling: 无效的标记: -parameters`,错误中的无效标记可能是因为使用的 JDK 版本不支持某些编译参数,体现了 JDK 版本相关问题 [^1]。 - **编译代码本身存在问题**:项目代码中存在语法错误依赖问题或者其他编译时错误。如 `Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project portal-core: Compilation failure An unknown compilation problem occurred`,这表明代码编译时出现未知问题,可能是代码本身存在缺陷导致编译失败 [^3]。 ### 尝试解决办法 在当前出错的项目下,找到对应的 `pom.xml` 文件,在 `dependencies` 同级的地方插入以下代码,以配置JDK版本信息。 ```xml <build> <plugins> <!-- 配置当前项目的jdk版本信息 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> ``` 上述代码将 `maven-compiler-plugin` 的版本更新为 3.8.1,并将编译的源版本目标版本都设置为 11,编码设置为 UTF - 8,可能会解决因 JDK 版本不兼容导致的问题 [^5]。
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值