Define an environment variable in environment

export my_config=1337

To make a default value if the environment variable is not defined.

application.properties
1 # Default value
2 my_config=666
3 
4 # Take either a value from system environment or the default value.
5 my.config=${my_config}

Consume the variable somewhere in the application.

MyClass.java
1 @Component
2 public class MyClass {
3     @Value("${my.config}")
4     private int myValue;
5 
6     // Consume myValue ad libitum
7 }

Careful with the naming, it happened several times that I defined the default configuration with dot-notation and then the application did not work. Maybe use rather completely different names for the default value and the Spring property. You will keep staring at such piece of code wondering what is wrong

This is wrong
1 my.config=666
2 my.config=${my.config}