intellij idea: defined environment variable not recognized in maven pom

I have a java project opened in IntelliJ IDEA version 2018.1

I have defined an environment variable MY_VAR as /some/path/here in File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner -> Environment Variables

In my pom.xml, in the properties secion, I have defined my property as

<myProperty>${env.MY_VAR}/morepath</myProperty>

However, IntelliJ IDEA complains that “Cannot resolve symbol ‘env.MY_VAR'”

Answer

The possible two workarounds:

Setting the variable from terminal:

set env MY_VAR /some/path/here

Then restart your IDE.


Another options is to add export MY_VAR=/some/path/here ~/.profile file.
Then restart your computer.

Leave a Reply

Your email address will not be published. Required fields are marked *