in Spring boot

Spring boot Configuration properties

Spring boot is awesome and it allows you to configure your app using external properties file ( with no problem at all. Here is the example of the file located in the class path.

Injecting myValue is super easy, it can be done using @Value annotation like this

Same would go for other awesomeConfiguration values and here is the problem. We have a number of items that all belong to the group awesomeConfiguration it would be great if we could load all the values into the spring bean. Configuration properties to the rescue!


Configuration properties is set using 3 steps

1: Create POJO object where all property values are going to be loaded and specify @ConfigurationProperties with prefix to control what values are used.

2: enable Configuration properties in your spring config class using annotation @EnableConfigurationProperties

3: Inject AwesomeConfiguration



Write a Comment