You can read a system environment variable in a Spring Boot Java application by using the System.getenv()
method. To determine the stage that the application is currently running, you can set an environment variable in the deployment process (e.g., when deploying with Helm to AKS) that holds this information, and then access that variable in your code.
For example, you could set an environment variable named APPLICATION_STAGE
with the value development
, staging
, or production
.