Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@ConfigurationProperties Spring Boot Configuration Annotation Processor not found in classpath

I try to make completion for custom properties in Spring Boot.

I tried to create a simple project via IntelliJ IDEA 2016.3:

  1. Created a new Gradle project with Spring Boot Initializer (I haven't checked anything at all).
  2. Created a new class Properties.

When I annotated it with @ConfigurationProperties, the next notification has appeared: notification

The documentation said that I should add the following to my project:

dependencies {     optional "org.springframework.boot:spring-boot-configuration-processor" }  compileJava.dependsOn(processResources) 

After that, I tried to rebuild the project and enable annotation processors in settings but the notification hasn't gone. Completion doesn't work too (I created a string my).

like image 874
Feeco Avatar asked Mar 16 '17 16:03

Feeco


People also ask

What is spring boot configuration processor?

spring-boot-configuration-processor is an annotation processor that generates metadata about classes in your application that are annotated with @ConfigurationProperties .

What are the ways in which spring boot can read configurations?

Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration.

What is configuration annotation in spring?

Spring @Configuration annotation is part of the spring core framework. Spring Configuration annotation indicates that the class has @Bean definition methods. So Spring container can process the class and generate Spring Beans to be used in the application.


2 Answers

I had the same problem. I use idea 2017.2 and gradle 4.1, and some blog said you should add:

dependencies {     optional "org.springframework.boot:spring-boot-configuration-processor" } 

But I changed it to this:

dependencies {     compile "org.springframework.boot:spring-boot-configuration-processor" } 

And the warning is gone.

like image 84
Icex Avatar answered Sep 17 '22 14:09

Icex


According to the Spring Boot docs, the correct configuration since Gradle 4.6 is

dependencies {     annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'     // ... } 

IntelliJ IDEA supports annotationProcessor scope since build 193.3382 (2019.3). Don't forget to enable annotation processing in IntelliJ IDEA settings.

like image 23
naXa Avatar answered Sep 16 '22 14:09

naXa