Search code examples
javaspringenvironmentregion

How to set Run Configuration's environment region in Java Spring, STS?


I am trying to run a Java Spring project in STS locally rather than on the server. This project takes on a REGION which I am trying to set to DEV, and I'd like to set it in Run Configurations so that I don't get this: "java.lang.RuntimeException: Problem with required environment variable REGION!"

Any help, possibly with screenshots or something would be very appreciated, thanks.


Solution

  • Multiple options here:

    1. Via menu Run Run Configurations Arguments (second tab) add VM arguments -DREGION=DEV

    2. Via menu Run Run Configurations Environment (tab six) Add... arguments REGION = DEV

    Note: if you use both options, then VM arguments -DREGION=DEV will win

    VM arguments can be used to launch your app via CLI:

    java -DREGION=DEV -jar your_nice_app.jar