项目切换Java21

目录

项目启动流程

遇到的问题


目前我们所有的项目都是Java8的,突然交接过来一个Java21的项目,项目启动耗时挺久,本篇记录下问题以及解决方案

项目启动流程

  1. 下载Java21

  2. 配置Java21

本机环境变量配置

确保path里有Java21路径

  1. idea配置

参考:IDEA切换JDK版本超详细步骤_ideal jdk17和21在哪里选择-CSDN博客

  1. 此时就可以编译成功了
  1. 单测启动

需要增加运行时参数,并且在当前页面执行

VM options

--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.math=ALL-UNNAMED
--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.dv.util=ALL-UNNAMED

遇到的问题

  1. [ERROR] Failed to execute goal on project xmstore-crm-api: Could not resolve dependencies for project com.xiaomi.nr.xmstore:xmstore-crm-api:jar:1.0.0-SNAPSHOT: The following artifacts could not be resolved: org.apache.thrift:thrift:jar:0.5.0-mdf2.0.4, org.apache.dubbo:dubbo:jar:2.7.12-mone-java21-v22-SNAPSHOT: org.apache.thrift:thrift:jar:0.5.0-mdf2.0.4 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

配置了本地仓库,还是去公共仓库拉取jar包了

解决:参考【XXX was not found in https://repo.maven.apache.org/maven2 during a previous attempt.maven 设置了私有仓库,】_was not found in during a previous attempt-CSDN博客

将自己配置本地库,添加到最外层pom文件中

  1. Compilation failure [ERROR] javac: 无效的目标发行版: 21

Java21配置问题,按照上述配置即可

相关推荐
morris1312 个月前
【java21】java21新特性之记录模式
java·java21·记录模式