Spring Boot uses @ConfigurationProperties to get the yml configuration as a null value

Check your yml file name carefully, it can only be: application.yml (note that it is lowercase application)
These are not correct: Application.yml , dev-application.yml , settings.yml

Another easy mistake:

1 Forgot to add a setter method in the class .

2 Annotate when declaring the class:
@Component
@ConfigurationProperties(prefix = “student”)

3 Forget to load automatically when using:
@Autowired
Student student;

Guess you like

Origin blog.csdn.net/weixin_44215363/article/details/109274440