问题
Anyone know why I am unable to reference the User environment variables shown below (red box) but I am able to reference the System environment variables (green box) without any issues?
回答1:
Ok so, in short, they need to be placed in <environmentVariables>ENVIRONMENT VARIABLES GO HERE </environmentVariables>
within the POM for them to be picked up. As @Andrey pointed out in his reply, they do show as unresolved but will still work. You can stop them showing as unresolved using: <!--suppress UnresolvedMavenProperty -->
回答2:
IDE provides only some of the pre-defined environment variables for completion and validation. Other variables may be not resolved. For the error not to be reported you can use intention action to suppress it:
Also note that when defined in Run Configuration in IDE - the environment variables are only defined for this particular session that you launch using this configuration.
If you want for the environment variables to be picked up in pom.xml file you need to define it in the OS.
来源:https://stackoverflow.com/questions/63249980/unable-to-reference-environment-variables