ProjectLombok - 安装 Eclipse Luna 后在 Eclipse 中未定义方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26189167/
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-09-19 22:03:24  来源:igfitidea点击:

ProjectLombok - Method Undefined in Eclipse After Installing Eclipse Luna

javaeclipsemavenlombok

提问by The Gilbert Arenas Dagger

I downloaded Eclipse Luna and imported a stable existing Maven project which makes use of the @Getter and @Setter lombok annotations. The annotations are recognized, but Eclipse flags any calls to the getter or setter methods giving the error message

我下载了 Eclipse Luna 并导入了一个稳定的现有 Maven 项目,该项目利用了 @Getter 和 @Setter lombok 注释。注释被识别,但 Eclipse 会标记对 getter 或 setter 方法的任何调用,并给出错误消息

The method getSomething() is undefined for the type Foo

Foo 类型的 getSomething() 方法未定义

Unlike other stackoverflow questions, like this, I am experiencing this issue despite the fact that I have updated my eclipse.ini, and added the lombok.jar to the same directory as my eclipse.exe and eclipse.ini file. The eclipse.ini changes made no difference though, I still have error markets everywhere!

与其他 stackoverflow 问题不同,像这样,尽管我已经更新了 eclipse.ini 并将 lombok.jar 添加到与 eclipse.exe 和 eclipse.ini 文件相同的目录中,但我还是遇到了这个问题。尽管 eclipse.ini 的更改没有任何区别,但我仍然到处都有错误市场!

eclipse.ini

eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.7.0_51\bin\javaw.exe
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

I have done a project > clean, I have tried using the full path to my lombok jar, I have exited and restarted Eclipse all to no avail.

我已经完成了一个项目 > 干净,我已经尝试使用我的 lombok jar 的完整路径,我已经退出并重新启动了 Eclipse,但无济于事。

What am I missing here? Thanks for any help!!!

我在这里错过了什么?谢谢你的帮助!!!

采纳答案by The Gilbert Arenas Dagger

I experienced this issue because the lombok version my project used, 0.9.3, was not supported in Eclipse Luna. I have upgraded my version to 1.14.8 and now everything is working as expected.

我遇到了这个问题,因为我的项目使用的 lombok 版本 0.9.3 在 Eclipse Luna 中不受支持。我已将我的版本升级到 1.14.8,现在一切都按预期工作。

See how to configure lombok in eclipse lunafor more information.

查看如何在 eclipse luna 中配置 lombok 以获取更多信息。

回答by maaartinus

Actually no real idea, but maybe something helps.

实际上没有真正的想法,但也许有些帮助。

Eclipse uses its own compiler, while Maven probably uses javac. So you normally have to get noth running and these two things are unrelated.

Eclipse 使用自己的编译器,而 Maven 可能使用javac. 所以你通常不需要运行,这两件事是无关的。

A single Eclipse restart was always sufficient for me.

一次 Eclipse 重启对我来说总是足够的。

Look in Help / About Eclipse SDK: Is there an Lombok entry?

查看帮助/关于 Eclipse SDK:是否有 Lombok 条目?

My eclipse.ini contains absolute paths:

我的 eclipse.ini 包含绝对路径:

-javaagent:/home/maaartin/eclipse/lombok.jar
-Xbootclasspath/a:/home/maaartin/eclipse/lombok.jar

but relative path must work too. The question is "relative to what?".

但相对路径也必须有效。问题是“相对于什么?”。

Normally, Lombok can find your Eclipse install directory and install itself. You have to do it manually, only when using non-standard install directories.

通常,Lombok 可以找到您的 Eclipse 安装目录并自行安装。您必须手动执行此操作,仅在使用非标准安装目录时。

Open the Error Log View, maybe there's something bad going on. Just in case, look at the log files on the disk, too.

打开错误日志视图,也许发生了一些不好的事情。以防万一,也请查看磁盘上的日志文件。

Eclipse-Lombok.png

Eclipse-Lombok.png

回答by Luiz Feij?o Veronesi

Maven repository for Project Lombok is set under provided scope at project home page

Project Lombok 的 Maven 存储库设置在项目主页提供的范围内

http://projectlombok.org/mavenrepo/

http://projectlombok.org/mavenrepo/

Just remove that scope and it works on Eclipse Luna with version 1.14.8.

只需删除该范围,它就可以在 1.14.8 版的 Eclipse Luna 上运行。