解决spring boot1.5以上版本@ConfigurationProperties提示“Spring Boot Configuration Annotation Processor not.."

刺骨的言语ヽ痛彻心扉 2022-05-17 11:27 169阅读 0赞

Springboot1.5以上版本,在使用 @ConfigurationProperties注解的时候会提示“Spring Boot Configuration Annotation Processor not found in classpath”,

70

这是因为新版本已经取消了对location的支持,替代方案是使用

@Configuration和@PropertySource进行组合使用,例如:

  1. @Primary
  2. @Configuration
  3. @PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true)

如果要使用指定属性前缀”Prefix“,这时候还会使用到@ConfigurationProperties,提示依然会存在

70 1

解决方案是在POM文件中增加依赖

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-configuration-processor</artifactId>
  4. <optional>true</optional>
  5. </dependency>

导入依赖包后,异常提示消失,问题解决!

发表评论

表情:
评论列表 (有 0 条评论,169人围观)

还没有评论,来说两句吧...

相关阅读