大三下-项目实训-合代码报错记录

mvn clean install时报错[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.869 s
[INFO] Finished at: 2024-06-05T14:06:29+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (defau
lt-compile) on project PPT_project_backend: Fatal error compiling: 无效的标记: --release -> [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/MojoExecutionException

奇怪的问题,合的几个文件的Java版本都是17,但是合完后报错,gpt指导说可以改版本到21,仍然报错,gpt指导下加上了两个plugin,不爆红了。

这个错误通常是由于Maven编译器插件的配置不正确或JDK版本与Maven插件不兼容引起的。为了修复这个问题,请确保您的`pom.xml`文件中正确配置了Maven编译器插件,并且使用了兼容的JDK版本。

以下是解决步骤:

### 1. 配置Maven编译器插件

在`pom.xml`文件中,确保Maven编译器插件配置如下:

```xml
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.11.0</version>
            <configuration>
                <source>17</source> <!-- 使用您的实际JDK版本 -->
                <target>17</target> <!-- 使用您的实际JDK版本 -->
            </configuration>
        </plugin>
    </plugins>
</build>
```

### 2. 确认JDK版本

确保您正在使用与上述配置兼容的JDK版本。例如,如果配置中指定的是`17`,请确保您的系统中安装并使用的是JDK 17。

### 3. 清理和重新构建项目

在命令行中执行以下命令:

```bash
mvn clean install
```

### 示例完整的`pom.xml`

这是一个示例`pom.xml`文件,包含Apache POI依赖和正确配置的Maven编译器插件:

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>ppt_project_backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <java.version>17</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
```

### 验证JDK版本

您可以通过以下命令来检查当前使用的JDK版本:

```bash
java -version
```

确保输出结果与`pom.xml`中的`<source>`和`<target>`版本匹配。

通过上述步骤,您应该能够解决Maven编译问题并成功构建项目。如果问题仍然存在,请提供更多详细信息以便进一步诊断。

后来版本还是要17,把插件里面17不支持的预览哪那行删掉即可

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_62663319

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值