Property Handling and Profiles
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