Environment Variable with Maven

前端 未结 9 2118
攒了一身酷
攒了一身酷 2020-11-28 03:24

I\'ve ported a project from Eclipse to Maven and I need to set an environment variable to make my project work.

In Eclipse, I go to \"Run -> Run configurations\" and

9条回答
  •  [愿得一人]
    2020-11-28 03:59

    The -D properties will not be reliable propagated from the surefire-pluging to your test (I do not know why it works with eclipse). When using maven on the command line use the argLine property to wrap your property. This will pass them to your test

    mvn -DargLine="-DWSNSHELL_HOME=conf" test
    

    Use System.getProperty to read the value in your code. Have a look to this post about the difference of System.getenv and Sytem.getProperty.

提交回复
热议问题