gpt4 book ai didi

java - maven升级源码版本

转载 作者:行者123 更新时间:2023-12-04 18:36:19 24 4
gpt4 key购买 nike

我有个问题。我在我的 Ubuntu 机器上安装了 Java 15.0.2:

java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
我还安装了 Maven:
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 15.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-15-oracle
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-66-generic", arch: "amd64", family: "unix"
现在,当我尝试构建包时,出现以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project Simulator: Compilation failure: Compilation failure:
[ERROR] /binance/Simulator/src/main/java/com/company/drivers/SimulatorDriver.java:[241,16] switch expressions are not supported in -source 7
[ERROR] (use -source 14 or higher to enable switch expressions)
[ERROR] /binance/Simulator/src/main/java/com/company/drivers/SimulatorDriver.java:[242,22] switch rules are not supported in -source 7
[ERROR] (use -source 14 or higher to enable switch rules)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Candlestick.java:[127,43] method references are not supported in -source 7
[ERROR] (use -source 8 or higher to enable method references)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Candlestick.java:[175,155] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Slope.java:[63,38] method references are not supported in -source 7
[ERROR] (use -source 8 or higher to enable method references)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Slope.java:[94,155] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Pattern.java:[76,35] method references are not supported in -source 7
[ERROR] (use -source 8 or higher to enable method references)
[ERROR] /binance/Simulator/src/main/java/com/company/models/Pattern.java:[102,155] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /binance/Simulator/src/main/java/com/company/deserializers/AgentStrategyConfigDeserializer.java:[21,163] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /binance/Simulator/src/main/java/com/company/deserializers/AgentStrategyPackageDeserializer.java:[27,163] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
看起来 Maven 中的 Java 版本是 7,但我需要在版本 15 上运行。我已经安装了 java,但是如何为我的 maven 升级/设置 java?

最佳答案

尝试将以下内容添加到您的 POM

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>15</release>
</configuration>
</plugin>

关于java - maven升级源码版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66385620/

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