In Spring Boot, we often need to read some predefined values from application.properties, as follows:
# application.properties my.food=pizza
If your project is written in Java, you can use @Value(“${name}”) to get the value of my.food.
@Value("${my.food}") private String myFood;
However, if it is written in Kotllin, the above method will not work. You need to use @Value(“\${name}”) instead, and the variable must be declared as lateinit var.
@Value("\${my.food}") private lateinit var myFood: String