简体   繁体   English

Lombok 无法与 IntelliJ 2020.3 社区版一起使用

[英]Lombok not working with IntelliJ 2020.3 Community Edition

I worked with Lombok without any problems until Today, when my Intellij was automatically updated to the latest version 2020.3 30th, November build.直到今天,我的 Intellij 自动更新到最新版本 2020.3 11 月 30 日版本之前,我一直在使用 Lombok 没有任何问题。 After that, any Lombok annotations is not recognised anymore.之后,不再识别任何 Lombok 注释。

My Java project still build from command line with Maven but annotations are completely ignored in the project and cannot run any unit tests manually.我的 Java 项目仍然使用 Maven 从命令行构建,但项目中的注释完全被忽略,无法手动运行任何单元测试。

Things I tried so far:到目前为止我尝试过的事情:

  • Reinstalled the Lombok plugin重新安装了 Lombok 插件
  • Restarted Intellij重新启动 Intellij
  • Restarted the laptop重新启动了笔记本电脑
  • Invalidated the cache缓存无效
  • Re-cloned the project from github从 github 重新克隆项目
  • Checked that the annotation processor is enabled检查注释处理器是否已启用

Nothing worked.没有任何效果。 What could have happened?可能发生了什么? Any idea on what I can try to do?关于我可以尝试做什么的任何想法?

To summarize go to IntelliJ Preferences (Cmd +,)总结 go 到 IntelliJ Preferences (Cmd +,)

Preferences -> Build, Execution, Deployment -> Compiler

search for this option:搜索此选项:

User-local build process VM options (overrides Shared options):

and add this value:并添加此值:

-Djps.track.ap.dependencies=false

A work around is here, until they fix the actual problem:解决方法在这里,直到他们解决实际问题:

https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0 https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0

(see screenshoot for IJ fix) (请参阅 IJ 修复的屏幕截图)

My problem was related to my lombok version我的问题与我的龙目岛版本有关

Before upgrade my IntelliJ to 2020.03 my lombok version was 1.18.10 and the lombok plugin 0.32-EAP在将 IntelliJ 升级到 2020.03 之前,我的 lombok 版本是1.18.10 ,lombok 插件是0.32-EAP

After upgrade my lombok dependency to 1.18.16 it start work again without any issues.将我的 lombok 依赖项升级到1.18.16后,它再次开始工作,没有任何问题。 Looks like the plugin is not bundled yet in the community edition.看起来该插件尚未捆绑在社区版中。

I don't if is necessary, but my first action was to uninstall the plugin when I read the README on Lombok Plugin repo如果有必要,我不需要,但是当我阅读 Lombok Plugin repo上的 README 时,我的第一个操作是卸载插件

I was using Lombok fine with 2020.2 and plugin, but in 2020.3.1 it should be (and it is) included我在 2020.2 和插件中很好地使用了 Lombok,但在 2020.3.1 中它应该(并且它是)包含在内

Lombok 插件捆绑,Idea 2020.3

...but I had compilation errors like Cannot resolve symbol 'log' (when using @Slf4j ) ...但是我遇到了编译错误,例如Cannot resolve symbol 'log' (使用@Slf4j时)

I solved the problem deleting.idea from project and opened it again...我解决了问题从项目中删除.idea 并再次打开它......

edit: it happened to me again today with new checkout (we do not have.idea in Git) and I had similar problem.编辑:今天我又遇到了新的结帐(我们在 Git 中没有.idea),我也遇到了类似的问题。 Not sure if that was a fix, but I checked the plugin (it is not on screenshot above), it started working after, but I built it from cmd (Maven) and tried few other things, so I'm not sure what is a real fix不确定这是否是一个修复,但我检查了插件(它不在上面的屏幕截图中),它开始工作,但我从 cmd(Maven)构建它并尝试了一些其他的东西,所以我不确定是什么真正的修复

Seems like lombok is not bundled in Community edition of 2020.3 version.似乎 lombok 没有捆绑在 2020.3 版本的社区版中。 Fix is expected in 2020.3.1 version.预计在 2020.3.1 版本中修复。

From Lombok plugin GitHub issue来自Lombok 插件 GitHub 问题

Sorry guys, I have to confirm, it was forgotten to add it properly into the last community build.抱歉,我必须确认一下,忘记将其正确添加到上一个社区构建中。 See bug on Jetbrains Yourtrack: https://youtrack.jetbrains.com/issue/IDEA-257311请参阅 Jetbrains Yourtrack 上的错误: https://youtrack.jetbrains.com/issue/IDEA-257311

The Ultimate 2020.3 version contains lombok plugin as expected per default. Ultimate 2020.3 版本默认包含预期的 lombok 插件。

lombok plugin should be included in both IntelliJ distribution (Ultimate and Community) starting with 2020.3 release.从 2020.3 版本开始,lombok 插件应包含在 IntelliJ 发行版(终极版和社区版)中。 Something get wrong, we are working to fix it.出了点问题,我们正在努力修复它。

Fix is now planned for IntelliJ Community release 2020.3.1现在计划修复 IntelliJ 社区版本 2020.3.1

Update更新

2020.3.1 Community is released and contains lombok plugin by default now 2020.3.1 社区发布,现在默认包含lombok插件

Please check in: Lombok plugin settings you didn't disable it unintentionally.请签入: Lombok 插件设置您没有无意中禁用它。

I managed to make it work on a gradle project (Intellij 2020.3.2) by using exactly this in build.gradle:通过在 build.gradle 中使用它,我设法使其在 gradle 项目(Intellij 2020.3.2)上工作:

annotationProcessor 'org.projectlombok:lombok:1.18.18'
implementation 'org.projectlombok:lombok:1.18.18'

I think important point is to declare it as "annotationProcessor" to include it in the gradle build.我认为重要的一点是将其声明为“annotationProcessor”以将其包含在 gradle 构建中。 I did not even have to mess around with "User-local build process VM options" and even "Enable Annotation Processing" is not ticked in Intellij Settings.我什至不必弄乱“用户本地构建过程 VM 选项”,甚至在 Intellij 设置中也没有勾选“启用注释处理”。 So I guess that gradle is taking care of the Lombok generation, and not IDEA.所以我猜想 gradle 正在照顾龙目岛一代,而不是 IDEA。 but at least it finally works after hours lost trying to fix IntelliJ.但至少在尝试修复 IntelliJ 数小时后它终于可以工作了。

Installing Lombok plugin and enabling the annotation processor should do the needful.安装 Lombok 插件并启用注释处理器应该是必要的。 If still issue persists then i think you should report a bug and see what they reply.如果问题仍然存在,那么我认为您应该报告错误并查看他们的回复。

This is the problem with lombok, whenever IntelliJ provides upgrade lombok starts crying.这就是 lombok 的问题,每当 IntelliJ 提供升级 lombok 就开始哭泣。 Same happened with IntelliJ 2020.2 IntelliJ 2020.2 也是如此

Now there are 2 solutions现在有2个解决方案

  1. Wait till the developers of lombok provide upgrade compatible with IntelliJ 2020.3等lombok的开发者提供兼容IntelliJ 2020.3的升级
  2. Downgrade IntelliJ to previous working version.将 IntelliJ 降级到以前的工作版本。 For me IntelliJ 2020.2 worked perfectly fine.对我而言,IntelliJ 2020.2 运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM