如何设置系统属性以在 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
How do I set a system property for compiling in Eclipse?
提问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):
您必须执行以下步骤(抱歉,我没有环境可以证明,仅凭文档):
- Create a maven build by choosing on the selected pom of your project
Run > Maven...
- Enter the relevant goal, and press add in the arguments table.
- Enter there your system property as name:
someproperty
and value:true
. - Then start your maven build by pressing Run.
- 通过选择项目的选定 pom 来创建 Maven 构建
Run > Maven...
- 输入相关目标,然后在参数表中按添加。
- 在那里输入您的系统属性作为 name:
someproperty
和 value:true
。 - 然后按运行开始你的 Maven 构建。
See the following resources for details:
有关详细信息,请参阅以下资源:
- Creating a Java application launch configuration
- Set System Property for JUnit Runner (Eclipse) to test a Spring Web App
After having access to an Eclipse again, here are some screenshots:
再次访问 Eclipse 后,以下是一些屏幕截图:
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).
不知道有没有简单的方法来配置默认的运行配置。您可以提供一个空的,在那里输入参数,然后复制该运行配置,稍后添加其他参数。复制按钮位于第二个按钮的左上方(用红色矩形标记)。