遇到问题:使用@ConffigurationProperties 配置Car属性 Properties中mycar.brand与Car属性相对应
原因:@ConfigurationProperties(prefix =“author”)没有指定classpath时,IDEA提示没有找到classpath。
高版本的Spring Boot中@ConfigurationProperties注解去掉了localhost属性,导致发生这个错误,所以建议还是直接从配置文件中读取字段而不是获取对象。
解决方法
只有需要在pom.xml中添加 spring-boot-configuration-processor依赖