What is the injection sequence of bean in springboot?

this is a business logic class that uses the properties in the application.yml file (see figure queueNum)
clipboard.png
application.yml
clipboard.png

I expect the springboot application to output "maxCost = 5" when it runs, but actually output "maxCost = 0". I think this may be due to the different instantiation and injection order of bean, but I did not find the relevant code. does anyone know why? How can I solve this problem?

Aug.11,2021

@ Value and @ Autowired belong to setter injection. When Spring is equipped with Bean, it first creates an object (executes the constructor), and then performs setter injection.


solved, as shown in the figure, you can use @ PostConstruct

clipboard.png

Menu