[英]Java 17 with Maven Wrapper results in Unrecognized VM option 'MaxPermSize=512m'
I use OpenJDK 17 with Maven Wrapper 3.8.2 from Spring Initializr (Maven project, JAR packaging, Java 17, Spring Boot 2.6.0).我使用OpenJDK 17和Spring Initializr的 Maven Wrapper 3.8.2(Maven 项目、JAR 打包、Java 17、Spring Boot 2.6.0)。 No additional dependencies.
没有额外的依赖。
user@DESKTOP-U2OU5HG MINGW64 /c/Projects/my-project (master) $ java -version openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
Upon running any of ./mvnw.cmd -version
or ./mvnw.cmd clean install
, I always get the following message:在运行任何
./mvnw.cmd -version
或./mvnw.cmd clean install
时,我总是收到以下消息:
Unrecognized VM option 'MaxPermSize=512m' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
Switching to OpenJDK 16.0.2 resolves the issue, however, I need to work with Java 17.切换到OpenJDK 16.0.2解决了这个问题,但是,我需要使用 Java 17。
How to get it run?如何让它运行? There is nowhere
MaxPermSize=512m
set.没有设置
MaxPermSize=512m
。
Indeed -XX:MaxPermSize=size
is labelled as follows according to Java® Development Kit Version 16/17 Tool Specifications (see the links):实际上
-XX:MaxPermSize=size
根据 Java® Development Kit Version 16/17 Tool Specifications 标记如下(请参阅链接):
The Maven Wrapper in the mvnw.cmd
script, however, aside from the required JAVA_HOME
, uses also a bunch of optional environment variables such as M2_HOME
and these starting with MAVEN_
prefix.然而,
mvnw.cmd
脚本中的 Maven 包装器,除了必需的JAVA_HOME
之外,还使用了一堆可选的环境变量,例如M2_HOME
和这些以MAVEN_
前缀开头的变量。
The important one is MAVEN_OPTS
where such a removed Java option can appear causing the inability to start the JVM on the newer version.重要的是
MAVEN_OPTS
,其中可能会出现这样一个已删除的 Java 选项,从而导致无法在较新版本上启动 JVM。 In my case, I had something like:就我而言,我有类似的东西:
MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=512m -Dfile.encoding=UTF-8"
The solution is either to remove the option from the environment variables or add this line to the Maven Wrapper script to override the MAVEN_OPTS
value, In the minimal form:解决方案是从环境变量中删除选项或将此行添加到 Maven Wrapper 脚本以覆盖
MAVEN_OPTS
值,以最小形式:
MAVEN_OPTS=
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.