如何设置系统属性以在 Eclipse 中进行编译?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16499958/
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-09-10 21:42:24  来源:igfitidea点击:

How do I set a system property for compiling in Eclipse?

eclipsemavensystem-properties

提问by Janek

When I build my project from the command line with Maven, I can pass in a property using

当我使用 Maven 从命令行构建我的项目时,我可以使用

-Dsomeproperty=true

For example:

例如:

 mvn clean package -Dsomeproperty=true

How do I do the same when building in Eclipse?

在 Eclipse 中构建时如何做同样的事情?

回答by mliebelt

You have to do the following steps (and sorry, I have no environment to prove it, just from documentation):

您必须执行以下步骤(抱歉,我没有环境可以证明,仅凭文档):

  1. Create a maven build by choosing on the selected pom of your project Run > Maven...
  2. Enter the relevant goal, and press add in the arguments table.
  3. Enter there your system property as name: somepropertyand value: true.
  4. Then start your maven build by pressing Run.
  1. 通过选择项目的选定 pom 来创建 Maven 构建 Run > Maven...
  2. 输入相关目标,然后在参数表中按添加。
  3. 在那里输入您的系统属性作为 name:someproperty和 value: true
  4. 然后按运行开始你的 Maven 构建。

See the following resources for details:

有关详细信息,请参阅以下资源:

After having access to an Eclipse again, here are some screenshots:

再次访问 Eclipse 后,以下是一些屏幕截图:

  • enter image description here
  • enter image description here
  • 在此处输入图片说明
  • 在此处输入图片说明

The first shows how to configure an existing build (in Eclipse named a run configuration) with the relevant property. and the second shows the command that is then triggered (with the include -Dsomeproperty=true).

第一个展示了如何使用相关属性配置现有构建(在 Eclipse 中名为运行配置)。第二个显示然后触发的命令(使用 include -Dsomeproperty=true)。

I do not know if there is an easy way to configure the default run configuration. You may provide an empty one, enter there the parameter, and copy then that run configuration adding the additional parameters later. The copy button is on the left top the second one (with the red rectangle marking it).

不知道有没有简单的方法来配置默认的运行配置。您可以提供一个空的,在那里输入参数,然后复制该运行配置,稍后添加其他参数。复制按钮位于第二个按钮的左上方(用红色矩形标记)。