10

Is there a way to set ENV variables through tomcat7-maven-plugin such that they appear in System.getenv()?

The system properties can be set using the <systemProperties> that appear in System.getProperties() map. I am looking for a similar way to pass environment variables.

Vikdor
  • 23,934
  • 10
  • 61
  • 84

2 Answers2

0

Is there a way to set ENV variables through tomcat7-maven-plugin such that they appear in System.getenv()?

Yes and no. You can pass ENV variables but they wont appear by System.getenv(). Example:

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <foo>${env.FOO}</foo>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Grim
  • 1,938
  • 10
  • 56
  • 123
-1

This has been answered here: Setting User Environment Variables for tomcat on Windows

From an admin command prompt do the following command:

tomcat8 //US//YourServiceName ++Environment varname=value

You can set more than one variable by separating them with a semicolon (;) or a hash (#).

adinapiza
  • 17
  • 5
  • 1
    This will not help setting environment variables when running the Tomcat Maven plugin as part of a build – prunge Aug 03 '18 at 08:02