gradle build --warning-mode=all warning annotation processors deprecated use processor path instead

时间:2018-03-23 00:38:58

标签: spring-boot gradle build.gradle

when I do gradle clean build --warning-mode=all, I get the following warning:

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
}

I do not understand what is the warning about. I am fairly new to Gradle. I need help understanding what are the annotation processors that I am supposedly using and how to use processor path instead.

1 个答案:

答案 0 :(得分:1)

什么是annotation processors?

  

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

我应该如何使用它?

  

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

如何使用处理器路径?

  

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

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

或者,您可以在编译器参数中放置-proc:none以忽略它guideline