Skip to main content

Spring boot application.properties

In a application.properties file you can use place holders to reference environment variables rather than hard coding the value. For example: Instead of writing your application.properties like so:

// application.properties
aws.region=east

Which is fine but then if you have sensitive data which you wouldn't want to commit to the GitHub repositories you would need to use place holders and store those secrets in your environment variables which Spring Boot can then substitute in when is parsing the .properties files.

// application.properties
db.secrets=${DB_SECRETS}

If you write this and store your DB_SECRETS as an environment variable, it will be substituted in when the Spring boot application is ran, then you can access it using @Value annotation in your application.

This is much safer compared to hard coding it into your .properties file.

This is not a feature of Intellij IDEA, it is a native functionality by Spring Boot.

Extra note

The placeholders within application.properties can refer to either of the following

  1. Environment variables
  2. System property
  3. Another application.properties variable

It is very flexible.