Spring-boot: No processor claimed any of these annotations

Created on 19 Jul 2016  路  5Comments  路  Source: spring-projects/spring-boot

Building a Spring Boot maven project with Lombok dependency using -Xlint:all compiler option produces a compiler warning

COMPILATION WARNING :
-------------------------------------------------------------
No processor claimed any of these annotations: org.springframework.boot.autoconfigure.SpringBootApplication
1 warning

-Xlint -enables all recommended warnings, see javac docs for more details.

Reproduction steps

  • Create a new Spring Boot 1.4.0 RC1 maven project with Spring Initializr with Lombok dependency
  • Modify the build section of the pom file to include maven compiler flag -Xlint:all
<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
            <showDeprecation>true</showDeprecation>
            <showWarnings>true</showWarnings>
            <compilerArgs>
               <arg>-Werror</arg>
               <arg>-Xlint:all</arg>
            </compilerArgs>
         </configuration>
      </plugin>
      <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
   </plugins>
</build>
  • Expect this output
COMPILATION WARNING :
-------------------------------------------------------------
No processor claimed any of these annotations: org.springframework.boot.autoconfigure.SpringBootApplication
1 warning
-------------------------------------------------------------
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
warnings found and -Werror specified
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------

If you remove lombok dependency from the pom file, the project builds successfully.

invalid

Most helpful comment

You can add -Xlint:-processing to your compiler arguments to silence this warning. You can combine this with -Xlint or -Xlint:all to still run lint on everything else.

All 5 comments

Might be related to this bug in Lombok.

This doesn't really have anything to do with Lombok specifically. It will happen with any annotation processor on the classpath. The warning is indicating that annotation processing was performed during compilation and that none of the annotation processors handled an annotation. Note that there's nothing special about @SpringBootApplication and that it'll warn about any unhandled annotation

IMO, it's not a very helpful warning as it assumes that every annotation in a project's code will be handled by an annotation processor. Given that anyone can write an annotation and that there are many other uses for annotations other than processing during compilation, that assumption seems flawed to me.

I think you have two choices:

  1. Ignore the warning
  2. Write your own annotation processor that does nothing other than using @SupportedAnnotationTypes to declare all of the annotations that you want to use in your code that you don't want to be warned about.

I tried your second proposed solution:

@SupportedAnnotationTypes("org.springframework.*")
public class AnnotationProcessor extends AbstractProcessor {

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        return true;
    }

}

and now I get this warning

No processor claimed any of these annotations: javax.annotation.processing.SupportedAnnotationTypes,org.springframework.boot.autoconfigure.SpringBootApplication

Same result when trying to declare all annotations

@SupportedAnnotationTypes("*")

I'd guess your annotation processor is not running as an annotation processor but is having its source processed by an annotation processor. That would explain why it hasn't removed org.springframework.boot.autoconfigure.SpringBootApplication and has added javax.annotation.processing.SupportedAnnotationTypes to the list of unprocessed annotations.

You can add -Xlint:-processing to your compiler arguments to silence this warning. You can combine this with -Xlint or -Xlint:all to still run lint on everything else.

Was this page helpful?
0 / 5 - 0 ratings