Java MAVEN_OPTS 环境变量有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25621601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:48:47  来源:igfitidea点击:

What does the MAVEN_OPTS environment variable do?

javamaven

提问by tk_

For example:-

例如:-

MAVEN_OPTS=" -Xms512m -Xmx1024m -XX:MaxPermSize=1024m"
export MAVEN_OPTS

What does "-Xms512m -Xmx1024m -XX:MaxPermSize=1024m"mean?

什么"-Xms512m -Xmx1024m -XX:MaxPermSize=1024m"意思?

采纳答案by tk_

After going through above comments i clarify my doubts about MAVEN_OPTS and maven semantics. Kindly refer thislink and go through the document.

经过上述评论后,我澄清了我对 MAVEN_OPTS 和 maven 语义的疑虑。请参考链接并阅读文档。

    -Xmsn
            Specifies the initial size, in bytes, of the memory allocation pool. This value 
must be a multiple of 1024 greater than 1 MB. Append the letter k or K to indicate kilobytes,
 or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. See Garbage Collector Ergonomics at
            [http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html][2]

            Examples:

            -Xms6291456
            -Xms6144k
            -Xms6m

      -Xmxn
            Specifies the maximum size, in bytes, of the memory allocation pool. This value 
must a multiple of 1024 greater than 2 MB. Append the letter k or K to indicate kilobytes, or m
 or M to indicate megabytes. The default value is chosen at runtime based on system 
configuration.

            For server deployments, -Xms and -Xmx are often set to the same value. See Garbage
 Collector Ergonomics at
            [http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html][3]

            Examples:

            -Xmx83886080
            -Xmx81920k
            -Xmx80m

回答by Gimby

Documentation is great but it is not always complete. There are some additional things which you can do to figure things out yourself. In this case you know that MAVEN_OPTS is an environmental variable, which likely means it is used in shell script. So open up for example mvn.bat and search for MAVEN_OPTS to see how it is used.

文档很棒,但并不总是完整的。您还可以做一些额外的事情来自己解决问题。在这种情况下,您知道 MAVEN_OPTS 是一个环境变量,这可能意味着它在 shell 脚本中使用。所以打开例如 mvn.bat 并搜索 MAVEN_OPTS 以查看它是如何使用的。

You will find it is simply a way to specify Java command line arguments which will be in effect for the execution of Maven itself. As an example in the past I needed to increase the default permgen size to prevent issues during execution of a complex build.

您会发现它只是一种指定 Java 命令行参数的方法,该参数将对 Maven 本身的执行有效。作为过去的一个例子,我需要增加默认的 permgen 大小以防止在执行复杂构建期间出现问题。