17

Warning

On IntelliJ, I am getting a Spring Boot Configuration Annotation Processor not configured for having @ConfigurationProperties. Below is my class:

@Configuration
@ConfigurationProperties(prefix = "abc")
@Data
@RefreshScope
class Config {
    String propA;
    String propB;
    ...
}

I am not sure what's causing this and when I click on the wrench for settings, I do not see any options to configure for metadata files.

夢のの夢
  • 5,054
  • 7
  • 33
  • 63
  • ...but does it break the application when you run it, though? I see this error often enough in IntelliJ and it hasn't posed an issue for me. – Makoto Apr 22 '20 at 15:28
  • Does this answer your question? [@ConfigurationProperties Spring Boot Configuration Annotation Processor not found in classpath](https://stackoverflow.com/questions/42839126/configurationproperties-spring-boot-configuration-annotation-processor-not-foun) – Simon Martinelli Apr 22 '20 at 15:40

4 Answers4

10

I faced the same problem with IntelliJ IDEA 2020.2 and Maven 3.6.2. The solution was to explicitly set the annotation processor in the maven-compiler-plugin settings. I found the answer here:

  1. https://stackoverflow.com/a/48028193/9989732
  2. https://stackoverflow.com/a/64031211/9989732

The full configuration:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-configuration-processor</artifactId>
  <version>2.4.2</version>
  <optional>true</optional>
</dependency>

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.0</version>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
    <encoding>UTF-8</encoding>
    <annotationProcessorPaths>
      <path>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <version>2.4.2</version>
      </path>
      <path>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.8</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>
Ivan
  • 166
  • 1
  • 8
6

I resolved it by adding the following dependency to my pom file

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <version>2.2.6.RELEASE</version>
    <optional>true</optional>
</dependency>
wero026
  • 1,187
  • 2
  • 11
  • 23
0

You can easily generate your own configuration meta-data 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. To use the processor, simply include spring-boot-configuration-processor as an optional dependency, for example with Maven you would add:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>
nono
  • 1
  • 1
0

For Gradle, like Maven, we need to add The appropriate annotation processor. To do so, add a line to the dependencies section in your build.gradle file.

dependencies {
    ...
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:'
    ...
}
nanotek
  • 2,959
  • 15
  • 25