Reputation: 24287
I've added:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
to my pom.xml
per intellij
's request/warning.
Now I'm seeing "Re-run Spring Boot Configuration Annotation Processor to update generated metadata".
How do I do what intellij
is asking me to do?
This link, B.2 Generating your own meta-data using the annotation processor, does not have instructions.
Upvotes: 181
Views: 168977
Reputation: 284
Simply do:
mvn clean verify
or click "verify" in you maven panel in IntelliJ.
On "clean" he will not recognize annotations and on "verify" he will generate them again and they will be immediately recognized, no need for restart or anything.
Upvotes: 0
Reputation: 2337
None of the above worked in my case, but brought me close. In the end explicitly defining all required annotationProcessors in the maven-compiler-plugin solved it for me. In my case this was: Spring-Boot + Lombok + MapStruct
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</annotationProcessorPath>
<annotationProcessorPath>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</annotationProcessorPath>
<annotationProcessorPath>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot-configuration-processor.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
Before that I always got some warnings in the Class + in the application.properties some properties were marked as "unusued", even when they were defined in a class with @ConfigurationProperties
Upvotes: 3
Reputation: 1
In the maven panel of Idea, clean and compile in the maven lifecycle worked for me.
Upvotes: 0
Reputation: 101
I had a similar issue using Gradle and Kotlin.
You should modify the build.gradle.kts
file to include the following:
//build.gradle.kts
plugins {
// ...
kotlin("kapt") version "1.5.31"
}
dependencies {
// ...
kapt("org.springframework.boot:spring-boot-configuration-processor")
}
Then, to generate the annotations:
./gradlew kaptKotlin
References: https://spring.io/guides/tutorials/spring-boot-kotlin/#_configuration_properties
Upvotes: 4
Reputation: 447
I just needed
@EnableConfigurationProperties({MY_PROPS_CLASS.class})
in Main Application class and it helped me to resolve this issue
Upvotes: 5
Reputation: 1872
I had the same problem. In my case I was missing the spring-boot-maven-plugin.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
as well as the @Data Lombok annotation
@Configuration
@ConfigurationProperties("logging.web")
@Data
public class LoggingWebConfiguration {
// ...
}
Obviously you can also just create the getter/setters yourself.
Then you must also remember to re-import and re-compile your project.
Upvotes: 0
Reputation: 509
Having included a dependency on spring-boot-configuration-processor
in build.gradle
:
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:2.4.1"
the only thing that worked for me, besides invalidating caches of IntelliJ and restarting, is
Reload All Gradle Projects
Clean
Build
Upvotes: 6
Reputation: 1387
For me, other answers didn't work. I had to go to open Files
and do Invalidate caches and restart
on Intellij. After that, everything worked fine again.
Upvotes: 12
Reputation: 3320
Upvotes: 5
Reputation: 1663
You can enable annotation processors in IntelliJ via the following:
Upvotes: 21
Reputation: 1352
None of these options worked for me. I've found that the auto detection of annotation processors to be pretty flaky. I ended up creating a plugin section in the pom.xml file that explicitly sets the annotation processors that are used for the project. The advantage of this is that you don't need to rely on any IDE settings.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
<annotationProcessors>
<annotationProcessor>org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor</annotationProcessor>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
<annotationProcessor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
Upvotes: 23
Reputation: 10512
None of the answers worked for me. If you just want to disable the message, go to Intellij Preferences -> Editor -> General -> Appearance, uncheck "Show Spring Boot metadata panel".
However, you can also live with that message, if it does not bother you too much, so to make sure you don't miss any other Spring Boot metadata messages you may be interested in.
Upvotes: 15
Reputation: 748
I had the same issue. The problem is that the Spring Boot annotation processor generates the spring-configuration-metadata.json
file inside your /target/classes/META-INF
folder.
If you happen to have ignored this folder in IntelliJ like me (because what the heck, who cares about classes files?), the file won't be indexed by your IDE. Therefore, no completion, and the annoying message.
Just remove target
from the ignore files/folders list, located in Settings > Editor > File Types > Ignore files and folders
.
Upvotes: 15
Reputation: 3200
Following these instructions worked for me: http://www.mdoninger.de/2015/05/16/completion-for-custom-properties-in-spring-boot.html
That message about having to Re-run the Annotation Processor is a bit confusing as it appears it stays there all the time even if nothing has changed.
The key seems to be rebuilding the project after adding the required dependency, or after making any property changes. After doing that and going back to the YAML file, all my properties were now linked to the configuration classes.
You may need to click the 'Reimport All Maven Projects' button in the Maven pane as well to get the .yaml file view to recognise the links back to the corresponding Java class.
Upvotes: 96