Want to improve as a dev?

I send a short email every workday about Spring topics, API development and improving as a dev.

I understand and agree to the privacy policy

Property Handling and Profiles

20.03.2018 by Jens in Spring Boot | Newsletter

When we start to define properties, sooner than later, we are facing the problem of having environment specific ones like DB connections, paths in the filesystem, etc.

Spring offers us a solution in the form of profiles. A profile is not tied to a system environment like dev, preprod, and production. It is an arbitrary identifier we can use to split up configuration.

However, a usual case is splitting up by runtime environment. Profile specific properties are using the naming convention:


They are placed along the regular application.properties and the same rules apply. When we activate multiple profiles, and the same property key is declared more than once, it will use the last one found.

A common way to activate a profile is by specifying it on the command line with –spring.profiles.active= , followed by a comma-separated list of active profiles, so for example, if we want to activate the profiles local and db it looks like:


comments powered by Disqus