gpt4 book ai didi

java - Maven编译错误(要求更高的JDK版本)

转载 作者:行者123 更新时间:2023-11-30 06:35:06 27 4
gpt4 key购买 nike

我今天做了一个新项目,想用 Maven 进行编译(我在 IntelliJ 上运行它)。确保将 JDK 级别更改为 1.8,这是我当前使用的,尝试编译,但我收到很多异常,要求我使用“-source 8”参数,因为默认级别是 1.5,我'我使用较新 JDK 版本的功能。

我已经很长时间没有使用 IntelliJ 了,谁能告诉我如何更改这些 Maven 编译参数或如何解决这个问题?

最佳答案

将其添加到 pom.xml

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

参见:https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

关于java - Maven编译错误(要求更高的JDK版本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45333930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com