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 nothing at all).
2. Created a new class Properties
.
3. When I annotated it with @ConfigurationProperties
, the next notification has appeared:
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 project and enable annotation processors in settings but the notification hasn’t gone. Completion doesn’t work too (I created a string my
).
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.
Answer:
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).
Answer:
I forgot to add propdeps-plugin. However, I remember that it didn’t work for me even with the plugin on 2016.3, So as @CrazyCoder mentioned, try to downgrade Gradle or download the new 2017.1 version (details).
Also you may receive Re-run Spring Boot Configuration Annotation Processor to update generated metadata
when you will solve this issue. For this, click Refresh all Gradle projects
(in Gradle side menu).
Answer:
It happens to me for two reasons in IDEA:
- Double check if your setting is picked (enabled) in IDEA: Preferences->Annotation Processors->Enable annotation processing.
- After update your Idea, check your plugins and update them. It happens that plugins become incompatible with your new IDEA version, so just click to update them.
Answer:
In version 2018.3 of IntelliJ, I solved this problem (as per this documentation) in the following way:
With Gradle 4.5 and earlier, the dependency should be declared in the
compileOnly configuration, as shown in the following example:dependencies { compileOnly "org.springframework.boot:spring-boot-configuration-processor" }
With Gradle 4.6 and later, the dependency should be declared in the
annotationProcessor configuration, as shown in the following example:dependencies { annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" }
Answer:
In maven project helps adding dependency spring-boot-configuration-processor and marking main class with @EnableConfigurationProperties(AppProperties.class).
Maybe somebody helps.
Answer:
I had the same problem with IntelliJ version 2018.1.2. I also had to define the actual version of spring-boot-configuration-processor in order to get it worked:
compile('org.springframework.boot:spring-boot-configuration-processor:2.0.1.RELEASE')
Answer:
following works for me:
buildscript {
repositories {
jcenter()
maven { url 'https://repo.jenkins-ci.org/public/' }
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath "io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
}
}
...
apply plugin: 'propdeps'
apply plugin: 'propdeps-eclipse'
apply plugin: 'propdeps-idea'
...
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-starter-parent:2.0.0.RELEASE'
}
}
...
dependencies {
compile "org.springframework.boot:spring-boot-starter"
compile "org.springframework.boot:spring-boot-starter-actuator"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" // for @ConfigurationProperties, make sure compileJava.dependsOn(processResources)
...
}
compileJava.dependsOn(processResources)
Answer:
For Kotlin projects, the working configuration since Gradle 4.6 is using annotation processor
apply plugin: "kotlin-kapt"
dependencies {
kapt("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
compileOnly("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
}