MAVEN_OPTS 与 mvn -D [英] MAVEN_OPTS vs. mvn -D

查看:115
本文介绍了MAVEN_OPTS 与 mvn -D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为两者都定义了相同的 - JVM 属性,但这两者之间显然存在差异,我找不到明确的解释.如果我在构建的 Jenkins Maven 中同时使用两者,则只有由 -D 设置的属性在 System.getProperties() 的 Java 应用程序中可见.尽管 MAVEN_OPTS 也应该传递给 JVM.我好像遗漏了什么.

I thought both define the same - JVM properties, but there is obviously a difference between those two and I cannot find a clear explanation. If I use both in Jenkins Maven built, only properties set by -D are visible in Java application by System.getProperties(). Although MAVEN_OPTS should be passed to JVM as well. Seems like I am missing something.

感谢解释.

推荐答案

MAVEN_OPTS 是一个环境变量,可让您将参数传递给运行 Maven 的 Java VM.

MAVEN_OPTS is an environment variable that lets you pass parameters to the Java VM running Maven.

因此,您可以使用它来设置堆和永久大小(例如 MAVEN_OPTS=-XX:MaxPermSize=256m).

Thus, you can do things like set the heap and perm size using it (e.g. MAVEN_OPTS=-XX:MaxPermSize=256m).

相反,-D 参数是命令行参数.Maven 已经在 J​​ava 中运行,因此您将无法控制 Java 相关参数.

In contrast, the -D parameter are command line parameters. Maven is already running in Java, so you wouldn't be able to control Java related parameters.

请参阅此页面命令行参数及MAVEN_OPTS说明.

See this page for an explanation of command line parameters and MAVEN_OPTS.

基于此,我猜测您看不到该变量的原因是它被用作 JVM 参数而不是属性.

Based on that, I'm guessing the reason why you don't see the variable is because it's being used as a JVM argument rather than a property.

也许这个答案会有所帮助你明白了吗?

Perhaps this answer will help you get them?

这篇关于MAVEN_OPTS 与 mvn -D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆