Use properties from environment or property source
You don't have to configure anything it's supported natively.
Spring Boot lets you externalize your configuration so that you can
work with the same application code in different environments. You can
use properties files, YAML files, environment variables, and
command-line arguments to externalize configuration. Property values
can be injected directly into your beans by using the @Value
annotation, accessed through Spring’s Environment abstraction, or be
bound to structured objects through @ConfigurationProperties.
It's done for you, so what you still have to do is to declare your variable in :
- Command Line arguments (--foo=bar)
- JNDI attributes from java:comp/env.
- Java System properties (System.getProperties()).
- OS environment variables.
Properties by environment (Profiles)
If you want to use property per environment (local, dev, production) you can use profiles, a dummy example is to have application-[profile].properties (where [profile] could be dev, prod ...) along with application.properties in the your classpath or externalized (refer to using spring.config.location ).
Note that application profile specific properties override those in application.properties