Post Thumbnail

Environment Variables in Spring Boot Properties: Override default values using Environment variables

In this video, we demonstrated how to use environment variables in Spring Boot application properties files to override the configured default values.

Engineers work in a team and each person has a preferred way of setting up their local development environment. Some prefer to use the default ports, and username/password while others customise to suit their taste.

Each Engineer in the team will at one point modify the codebase in the team’s scope and will need to run them locally.

Because the configured values in the application are not the same as what they have on their machine, some Engineers will temporarily modify the application properties and hope to undo the changes before committing their change. They often forget.

Some will create a special application-profile.properties and add it to the git ignore file.

The same challenge surfaces when all the Spring Boot applications are configured to run on the default port 8080, and we want to run two or more on the same local machine at the same time.

The process described in this video helps solve these challenges by showing how to use environment variables override that can be applied per application.

We will see how to edit Run configurations in IntelliJ IDEA and VS Code.

The complete source code is available on GitHub.

If you find this tutorial helpful, don’t forget to check out other articles. Share your thoughts or ask questions in the comments below!

Happy Coding

Seun Matt

Results-driven Engineer, dedicated to building elite teams that consistently achieve business objectives and drive profitability. With over 9 years of experience, spannning different facets of the FinTech space; including digital lending, consumer payment, collections and payment gateway using Java/Spring Boot technologies, PHP and Ruby on Rails