使用 annotationProcessor 和 log4j2 PluginProcessor 配置 gradle

Ann*_*ova 4 annotations gradle

我试图用 gradle 构建我的项目。我收到此错误:

"Detecting annotation processors on the compile classpath has been deprecated. Gradle 5.0 will ignore annotation processors on the compile classpath. The following annotation processors were detected on the compile classpath: 'org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor'.  Please add them to the annotation processor path instead. If you did not intend to use annotation processors, you can use the '-proc:none' compiler argument to ignore them."
Run Code Online (Sandbox Code Playgroud)

我知道我必须使用 annotattionProcessor 而不是编译。但实际上如何做到这一点。这是我的 gradle 文件依赖项的一部分:

dependencies {
    implementation 'org.apache.logging.log4j:log4j-api:2.11.1'
    implementation 'org.apache.logging.log4j:log4j-core:2.11.1'
}
Run Code Online (Sandbox Code Playgroud)

我试图像这样使用它(隐式方式),但它不起作用

dependencies {
    implementation 'org.apache.logging.log4j:log4j-api:2.11.1'
    implementation 'org.apache.logging.log4j:log4j-core:2.11.1'
    annotationProcessor 'org.apache.logging.log4j.core:config.plugins.processor.PluginProcessor'
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我吗?

Ann*_*ova 9

答案很简单:

dependencies {
    implementation 'org.apache.logging.log4j:log4j-api:2.11.1'
    annotationProcessor 'org.apache.logging.log4j:log4j-core:2.11.1'
}
Run Code Online (Sandbox Code Playgroud)