gradle build --warning-mode=所有已弃用的警告注释处理器改用处理器路径



当我执行gradle clean build --warning-mode=all时,我收到以下警告:

Putting annotation processors on the compile classpath has been deprecated and is scheduled to be removed in Gradle 5.0. Please add them to the processor path instead. If these processors were unintentionally leaked on the compile classpath, use the -proc:none compiler option to ignore them..

build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.10.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
repositories {
    mavenCentral()
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
    compile files("libs/ojdbc7.jar")
    compile "org.springframework.boot:spring-boot-configuration-processor"
    compile group: "javax.inject", name: "javax.inject", version: "1"
    runtime "org.springframework.boot:spring-boot-devtools"
    providedRuntime "org.springframework.boot:spring-boot-starter-tomcat"
    testCompile "org.springframework.boot:spring-boot-starter-test"
}
bootRepackage {
    enabled = false
}

我不明白警告是什么。我对 Gradle 相当陌生。我需要帮助了解我应该使用的annotation processors是什么以及如何使用processor path

什么是annotation processors?

注解处理器是充当钩子的 Java 模块/库 进入Java编译器的编译过程,分析源代码 用于用户定义注释的代码,然后处理(通过生成 编译器错误、编译器警告、发出源代码、字节码 ...).

我应该如何使用它?

您的编译依赖项之一必须带来注释 幕后的处理器。

如何使用处理器路径?

根据 Gradle 文档,您可以添加注释处理器 如下配置

dependencies {
    annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
    implementation 'com.google.dagger:dagger:2.8'
}

或者,您可以按照本指南将-proc:none放入编译器参数中以忽略它

相关内容

最新更新