Re-run Spring Boot Configuration Annotation Processor to update generated metadata – Spring

Photo of author
Written By M Ibrahim
azure-java-sdk intellij-idea maven spring

Quick Fix: Refer to this resource: http://www.mdoninger.de/2015/05/16/completion-for-custom-properties-in-spring-boot.html for guidance. After adding the necessary dependency or making property changes, rebuild the project. The linked configurations should appear in the YAML file view.

The Problem:

I have added the spring-boot-configuration-processor dependency to my pom.xml file, and IntelliJ is requesting me to "Re-run Spring Boot Configuration Annotation Processor to update generated metadata." However, the provided documentation ([link][1]) does not offer any instructions to guide me through this process. How can I carry out this action as requested by IntelliJ?

The Solutions:

Solution 1: Rebuilding the project after adding the dependency or making property changes

Explanation:

  1. To resolve the "Re-run Spring Boot Configuration Annotation Processor to update generated metadata" message, follow these steps:

  2. Ensure that you have added the <dependency> for spring-boot-configuration-processor in your pom.xml file with <optional>true</optional> to enable the annotation processor.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    
  3. After adding the dependency or making changes to your properties, rebuild the project. This will trigger the Spring Boot Configuration Annotation Processor to generate the necessary metadata.

  4. If you are using IntelliJ IDEA, you may need to click the ‘Reimport All Maven Projects’ button in the Maven pane to refresh the project dependencies and recognize the generated metadata.

  5. Once the project is rebuilt, the links between your YAML properties and the corresponding Java configuration classes should be established.

Note:

The "Re-run Spring Boot Configuration Annotation Processor to update generated metadata" message is a persistent notification in IntelliJ IDEA that indicates that the IDE is aware of changes in your project and is ready to update the generated metadata accordingly. However, you need to manually trigger the rebuilding of the project to apply these changes.

Solution 2: Specify Annotation Processors in Maven Configuration

If the automatic detection of annotation processors isn’t working reliably, you can explicitly configure the processors to use in your Maven project’s pom.xml file under the <plugins> section:

&lt;plugin&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    &lt;version&gt;3.7.0&lt;/version&gt;
    &lt;configuration&gt;
        &lt;compilerVersion&gt;1.8&lt;/compilerVersion&gt;
        &lt;source&gt;1.8&lt;/source&gt;
        &lt;target&gt;1.8&lt;/target&gt;
        &lt;annotationProcessors&gt;
            &lt;annotationProcessor&gt;org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor&lt;/annotationProcessor&gt;
            &lt;annotationProcessor&gt;lombok.launch.AnnotationProcessorHider$AnnotationProcessor&lt;/annotationProcessor&gt;
            &lt;annotationProcessor&gt;org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor&lt;/annotationProcessor&gt;
        &lt;/annotationProcessors&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;

This approach gives you more control over the annotation processors used in your project and doesn’t rely on IDE settings or automatic detection.

Solution 3: Enable Annotation Processor to Re-run Spring Boot Configuration Annotation Processor

To re-run Spring Boot Configuration Annotation Processor and update generated metadata, you can enable annotation processors in IntelliJ by following these steps:

  1. Open IntelliJ Settings:

    • Click on the "File" menu in the main menu bar.
    • Select "Settings" from the drop-down menu.
  2. Search for "Annotation Processors":

    • In the small search box located in the upper-left corner of the settings window, type "Annotation Processors."
  3. Enable Annotation Processing:

    • In the "Annotation Processors" section, locate the checkbox labeled "Enable annotation processing."
    • Click on the checkbox to enable annotation processing.
  4. Click "OK" to Save Changes:

    • Click the "OK" button in the lower-right corner of the settings window to save your changes.

After completing these steps, IntelliJ will re-run the Spring Boot Configuration Annotation Processor and update the generated metadata. This should resolve the issue you are experiencing.

Solution:

Several solutions are available to address the issue of needing to rerun the Spring Boot Configuration Annotation Processor to update generated metadata. Here’s one option that you can consider:

  1. Disable the Appearance Flag:
  2. Open IntelliJ preferences and navigate to Editor -> General -> Appearance. Here, uncheck the option labeled “Show Spring Boot metadata panel.” This change prevents the display of unnecessary Spring Boot metadata messages.

  3. Manage the Working Set:
  4. Within IntelliJ, ensure you have enabled the “Keep Current Session in Memory” option under Preferences -> Appearance & Behavior -> System Settings. By doing so, Spring Boot metadata messages will remain visible upon session restarts, enabling you to address any issues or changes accordingly.

  5. Clear Annotated Classes Folder:
  6. Look for a directory within your project structure called “.spring-boot-application” or “target/.spring-boot-application.” Remove any files or folders within this directory. Restarting IntelliJ will trigger the regeneration of necessary files, potentially resolving the issue.

  7. Use a Different IDE:
  8. As a temporary measure, switch to a different IDE, such as Eclipse or Visual Studio Code, to avoid the persistent message. Upon returning to IntelliJ, you may no longer encounter the issue.

These solutions aim to address the specific message you’re encountering, allowing you to continue working with Spring Boot without distractions. Please note that they might not be applicable to all scenarios, and you may need to explore additional options based on your specific requirements.

\n

Solution 5: Removing target from ignored files

\n

The "Re-run Spring Boot Configuration Annotation Processor to update generated metadata" message in IntelliJ IDEA occurs because the Spring Boot annotation processor generates a spring-configuration-metadata.json file in the /target/classes/META-INF folder. If this directory is added to the ignored files list in the IDE, the IDE can’t find or index the generated file.

\n

To address this issue and allow IntelliJ to index the generated metadata file, follow these steps:

\n

    \n

  1. Open IntelliJ IDEA and navigate to Settings (on macOS) or Preferences (on Windows).
  2. \n

  3. Select Editor > File Types.
  4. \n

  5. Go to Ignore Files and Folders.
  6. \n

  7. Remove target from the list of ignored files and folders.
  8. \n

  9. Click Apply and then OK to save the changes.
  10. \n

\n

Once you’ve made these changes, IntelliJ will re-index the /target/classes/META-INF folder, including the spring-configuration-metadata.json file, and the issue should be resolved.

\n

Alternatively, you can disable the Spring Boot annotation processor to prevent IntelliJ from generating the spring-configuration-metadata.json file. To do this, add the following line to the <dependencyManagement> section of your Maven pom.xml file:

\n

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

\n

This will prevent the annotation processor from running and generating the metadata file, and resolve the "Re-run Spring Boot Configuration Annotation Processor to update generated metadata" message in IntelliJ IDEA.