How to use environment variables in springboot
spring.config.import=optional:.env[.properties] with the above code in application file(application.properties / yml), you can use the environment variable in your project 1. in application file in application file, you can just use ${ variable_name } to use the variable. 2. in code in code(java files), you can use annotation @Value("{ variable_name}" ) to use the variable. 3. ConfigurationProperties if env variables are grouped with prefix (like apple.name and apple.count), you can easily map them through Configuration Properties. For example, instead of writing @Value("{apple.name}") and @Value("{apple.count}") respectively, you can just write @ConfigurationProperties(prefix = "apple") public class AppleProperties { private string name; private int count; }