Set java system properties in IntelliJ or Eclipse

2019-03-12 05:40发布

I have a project which runs correctly under the terminal command

mvn package exec:java -Dplatform.dependencies -Dexec.mainClass=Demo

Now, I need to debug it correctly (not terminal) with IntelliJ or Eclipse on Mac (preferably IntelliJ) but I have tried setting VM options in various places and nothing seems to work.

Where is the correct place to put these options: -Dplatform.dependencies -Dexec.mainClass=Demo?

3条回答
Luminary・发光体
2楼-- · 2019-03-12 06:02

In InteliJ goto "Run"->"Edit Configurations" In the new window, right panel, open the Junit and click on your test. Now, in the middle click on the "Configuration" tab and update the "VM options"

Note that you will need to do this for every test class, but you can remove all the test from the junit in the right panel and update it in the "Defaults"

查看更多
欢心
3楼-- · 2019-03-12 06:12

If you are like me, and showed up here trying to run tests that use the -P syntax instead of -D syntax, you can simply follow the instructions from MZF, but use the -D in place of the -P.

For example, my test on the command line executed as:

./gradlew -Penvironment=qa project:test

Using the -P in intellij on the VM line got rejected. Changing the -P to a -D ended up working, however.

查看更多
对你真心纯属浪费
4楼-- · 2019-03-12 06:15

In IntelliJ it works as follows: Go to configurations -> VM options and add the parameter/value pair:

-DmyParameter=value

Make sure you add a "D" after the "-"!

enter image description here

查看更多
登录 后发表回答