问题描述
在 Spring Boot 项目中,添加一个配置文件时,会提示“Spring Boot Configuration Annotation Processor not configured”,如下图所示:
原因分析
经过查询官网,需要配置注解处理器spring-boot-configuration-processor.jar
,官方原文:
You can easily generate your own configuration metadata file from items annotated with @ConfigurationProperties
by using the spring-boot-configuration-processor
jar. The jar includes a Java annotation processor which is invoked as your project is compiled.
解决方案
在 POM 文件中添加下面 Maven 依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
再打开配置文件,已经没有提示了,问题解决。