【问题标题】:gradle build --warning-mode=all warning annotation processors deprecated use processor path insteadgradle build --warning-mode=all 警告注释处理器已弃用,而是使用处理器路径
【发布时间】:2018-03-23 00:38:57
【问题描述】:

当我执行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

【问题讨论】:

    标签: spring-boot gradle build.gradle


    【解决方案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 忽略它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-06
      • 1970-01-01
      • 2018-10-12
      • 2017-10-22
      相关资源
      最近更新 更多