How to set up an environment variable in mvn pom?

Some plugins, like surefire, let you set them. There’s no way, in general, in the pom.

The doc for surefire is is here. Surefire will set environment variables for the duration of the run of the tests, not for anything else. And you have to make surefire fork.

In the configuration …

<configuration>
  <forkMode>always</forkMode>
  <environmentVariables>
     <var1>val1</var1>
  </environmentVariables>
</configuration>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)