错误:升级到 lombok 1.16.2 后包 javax.annotation 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28465603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:17:23  来源:igfitidea点击:

Error: package javax.annotation does not exist after upgrade to lombok 1.16.2

javaandroidlombokintellij-lombok-plugin

提问by copolii

My android project builds fine with lombok 1.16.0, but once I change my dependency to target 1.16.2, I get the following error everywhere I'm using a lombok annotation:

我的 android 项目使用 lombok 1.16.0 构建得很好,但是一旦我将依赖项更改为目标 1.16.2,我在使用 lombok 注释的任何地方都会收到以下错误:

Error:(20, 1) error: package javax.annotation does not exist

Error:(20, 1) error: package javax.annotation does not exist

The Android SDK does not include all javax packages. What I'm wondering is if this is a bug in 1.16.2 or do I now have to add a dependency to javax.annotation?

Android SDK 不包括所有 javax 包。我想知道这是 1.16.2 中的错误还是我现在必须添加依赖项javax.annotation

Note: This is in Android Studio with Lombok plugin 0.8.8

注意:这是在带有 Lombok 插件 0.8.8 的 Android Studio 中

采纳答案by Roel Spilker

You can disable the generation of javax.annotation.Generatedby putting the following line in a lombok.configfile in one of the top directories of your project:

您可以javax.annotation.Generated通过将以下行放在lombok.config项目顶级目录之一的文件中来禁用 的生成:

lombok.addGeneratedAnnotation = false

See the configuration documentationfor more information.

有关更多信息,请参阅配置文档

Disclosure: I am a Lombok Developer.

披露:我是龙目岛开发人员。

回答by Alex Perevozchykov

If you're facing same issue in Android Studio using gradle - add following line to build.gradle:

如果您在使用 gradle 的 Android Studio 中遇到同样的问题 - 将以下行添加到 build.gradle:

provided 'org.glassfish:javax.annotation:10.0-b28'

回答by Soham

The right answer for android development today is to use a version of dagger which is greater than 2.1 (because of the fixmentioned by @tomrozb is integrated in 2.1)

今天Android开发正确的答案是使用一个版本的匕首,它大于2.1(因为的修复由@tomrozb提到的集成在2.1)