ConfigurationProperties 注解常见错误
➢ 在 ConfigInfo 类中使用了 ConfigurationProperties 注解后,IDEA 会出现一个警告,
不影响程序的执行
错误提示:
Re-run Spring Boot Configuration Annotation Processor to update generated metadata

➢ 点击 open documentnation 跳转到网页,在网页中提示需要加一个依赖,我们将这
个依赖拷贝,粘贴到 pom.xml 文件中
不使用@Component注解就会报出红框内的错误:Not registered via @EnableConfigurationProperties or marked as Spring component
此时需要添加@Component注解声明将这个组件添加到容器才可以被使用
“当这个组件是容器中的组件时,才能使用容器提供的@ConfigurationProperties功能”

浙公网安备 33010602011771号