【问题标题】:No processor claimed any of these annotations没有处理器声称这些注释中的任何一个
【发布时间】:2021-11-25 02:04:48
【问题描述】:

从 java 8 升级到 java 11 并收到以下注释警告。请建议如何解决。

[WARNING] No processor claimed any of these annotations: 
/org.springframework.context.annotation.Primary,
/org.springframework.data.annotation.Id,
/org.springframework.context.annotation.ComponentScan,
/org.springframework.boot.autoconfigure.SpringBootApplication,
/org.springframework.boot.context.properties.ConfigurationProperties,
/org.springframework.data.mongodb.repository.Query,
/com.fasterxml.jackson.annotation.JsonInclude,
/javax.validation.constraints.NotNull,
/org.springframework.context.annotation.ImportResource,
/org.springframework.web.bind.annotation.DeleteMapping,
/org.springframework.web.bind.annotation.PostMapping

【问题讨论】:

  • 你在运行 java 11 之前尝试过编译吗?
  • 是的,这是在编译中显示的。
  • 将 springboot 添加到您的类路径或使用 maven 构建项目。确保您有互联网连接,允许下载 springboot 库。
  • 这看起来不像是一个真正的问题。请参阅此处提到的解释和详细信息:github.com/spring-projects/spring-boot/issues/6421

标签: java spring-tool-suite


【解决方案1】:

javac linter 有许多非常离谱的警告,您不能单独关闭它们。这是其中之一。我建议使用不同的 linter。

你不能关闭这个特定的警告,你只能关闭所有带有-processing标志到-Xlint的注释处理器警告,例如。

-Xlint:all,-serial,-processing

在 Maven 中:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <showWarnings>true</showWarnings>
                <compilerArgs>
                    <!-- We turn off:
                        - `serial` because we don't use Java serialization 
                          (and all it does is stupidly complain about the serialVersionUID)
                        - `processing` because it complains about every annotation
                    -->
                    <arg>-Xlint:all,-serial,-processing</arg>
                </compilerArgs>
            </configuration>
        </plugin>

您可以通过在compiler.properties 中搜索“warn.proc”来查看所有将被禁用的警告。您可以使用 javac --help-lint 查看所有 linter 选项。

【讨论】:

    猜你喜欢
    • 2021-06-12
    • 2017-06-16
    • 2019-01-30
    • 2018-07-05
    • 2019-03-20
    • 2021-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多