Eclipse Oxygen 的 Lombok 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45461777/
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
Lombok problems with Eclipse Oxygen
提问by Alex P.
I upgraded recently to the new Eclipse version (Oxygen). I downloaded the lombok.jar from the website and installed it. This is how the eclipse.ini
looks like after installation:
我最近升级到新的 Eclipse 版本 (Oxygen)。我从网站下载了 lombok.jar 并安装了它。这是eclipse.ini
安装后的样子:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
C:\Users\xxx\.p2\pool\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.500.v20170531-1133
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
[email protected]/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-javaagent:lombok.jar
I can use Lombok as seen here:
我可以使用 Lombok,如下所示:
But when using the getters/setters and/or constructors in other classes I get the this errors:
但是当在其他类中使用 getter/setter 和/或构造函数时,我得到了这个错误:
Also these are my Eclipse and Lombok versions:
这些也是我的 Eclipse 和 Lombok 版本:
Eclipse Java EE IDE for Web Developers.
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/
Anyone knows how I can fix it?
有谁知道我该如何修复它?
回答by dkb
My env: java version "1.8.0_144"
我的环境:java 版本“1.8.0_144”
Eclipse: Eclipse Java EE IDE for Web Developers. Version: Oxygen Release (4.7.0) Build id: 20170620-1800
Eclipse:面向 Web 开发人员的 Eclipse Java EE IDE。版本:氧气释放 (4.7.0) 版本号:20170620-1800
Exit Eclipse(if it is open) and downloaded jar from https://projectlombok.org/download
execute command:
java -jar lombok.jar
This command will open window as shown here https://projectlombok.org/setup/eclipse, install and quit the installer.
Add jar to build path/add it to pom.xml.
e.g. for Gradle build
退出 Eclipse(如果它是打开的)并从https://projectlombok.org/download下载 jar
执行命令:
java -jar lombok.jar
此命令将打开如下所示的窗口https://projectlombok.org/setup/eclipse,安装并退出安装程序。
添加 jar 以构建路径/将其添加到 pom.xml。
例如对于 Gradle 构建
annotationProcessor("org.projectlombok:lombok")
compileOnly("org.projectlombok:lombok")
- restart eclipse.
- Go to Eclipse --> About Eclipse --> check 'Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/'
- To enable Lombok for the project:
Enable annotation processing
in the respective IDE. That's it. It worked. I did not change eclipse init script.
- 重启日食。
- 转到 Eclipse --> 关于 Eclipse --> 检查 'Lombok v1.16.18 "Dancing Elephant" 已安装。https://projectlombok.org/'
- 为项目启用 Lombok:
Enable annotation processing
在相应的 IDE 中。就是这样。有效。我没有更改 eclipse init 脚本。
Note: Read the note in following image regarding -vm options If you start Eclipse with a custom -vm parameter, you'll need to add:
注意:阅读下图中关于 -vm 选项的说明如果您使用自定义 -vm 参数启动 Eclipse,则需要添加:
-vmargs -javaagent:<path-to-lombok-jar>/lombok.jar
as parameter as well
也作为参数
Above steps works for Photon Release (4.8.0)
- Lombok v1.18.2
, eclipse: Oxygen.3a Release (4.7.3a)
- Lombok v1.18.0
and eclipse: Neon.3 Release (4.6.3)
- Lombok v1.18.2
以上步骤适用于Photon Release (4.8.0)
- Lombok v1.18.2
、eclipse: Oxygen.3a Release (4.7.3a)
-Lombok v1.18.0
和eclipse: Neon.3 Release (4.6.3)
-Lombok v1.18.2
fyi,
For JDK - 10 and 11 support:
Lombok version should be at least v1.18.4 (October 30th, 2018) or higher.
仅供参考,
对于 JDK - 10 和 11支持:Lombok 版本应至少为 v1.18.4(2018 年 10 月 30 日)或更高版本。
回答by aribeiro
For MacBook Pro users (e.g. running macOsSierra v10.12.6), in order to install lombokon Eclipse Oxygen (4.7.0) or Photon (4.8.0), using Java 1.8 (1.8.0_144), just do the following actions:
对于MacBook Pro的用户(例如运行MacOS的塞拉利昂v10.12.6),以便安装龙目岛的Eclipse的氧气(4.7.0)或光子(4.8.0) ,使用Java 1.8(1.8.0_144),只需执行以下操作:
- Download lombokfrom the site Project Lombok;
- Close your Eclipse IDE if it is open;
- Trigger lombokinstallation either by following the official installation stepsor by executing the command:
java -jar lombok.jar
; - If the lombokinstaller doesn't find your Eclipse IDE, you will be requested to enter the path to your Eclipse. You should input the path to your eclipse.inifile. In my case was
/tools/ide/eclipse/jee-oxygen/Eclipse.app/Contents/Eclipse/eclipse.ini
. - Quit the installer and open Eclipse.
On the menu bar, go to Eclipse > About Eclipseand validate that lombokis installed:
Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/
Be sure to scroll the text window down since the installed Lombok version appears in the text above the row of icons.
Finally, add lombokto your project's build path according to the building tool you're using. For Maven, for instance, use the following dependency:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.18</version> <scope>provided</scope> </dependency>
- 从网站Project Lombok下载lombok;
- 如果 Eclipse IDE 处于打开状态,请关闭它;
- 触发Lombok的安装或者通过以下所述的官方的安装步骤或通过执行命令:
java -jar lombok.jar
; - 如果lombok安装程序没有找到您的 Eclipse IDE,您将被要求输入 Eclipse 的路径。您应该输入eclipse.ini文件的路径。在我的情况下是
/tools/ide/eclipse/jee-oxygen/Eclipse.app/Contents/Eclipse/eclipse.ini
. - 退出安装程序并打开 Eclipse。
在菜单栏上,转到Eclipse > About Eclipse并验证lombok是否已安装:
Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/
确保向下滚动文本窗口,因为已安装的 Lombok 版本出现在图标行上方的文本中。
最后,根据您使用的构建工具将lombok添加到您的项目的构建路径中。例如,对于 Maven,使用以下依赖项:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.18</version> <scope>provided</scope> </dependency>
回答by Khanna111
Had problems with Eclipse Oxygen, Java 1.9and Lombok(on Mac OSX- windows/linuxshould be similar).
Eclipse Oxygen、Java 1.9和Lombok有问题(在Mac OSX 上- windows/linux应该类似)。
This is what I had to do:
这就是我必须做的:
- Download the latest
lombok: 1.16.20
- Open up eclipse, and check for updates and install all of them. Ensure that eclipse is updated to the latest.
- Exit eclipse.
java -jar lombok.jar
- Ensure that the location to Eclipse is correct in the installer window that pops up, I had to explicitly specify:
/[some-folder-heirarchy]/Eclipse.app/Contents/Eclipse/eclipse.ini
- 下载最新的
lombok: 1.16.20
- 打开eclipse,检查更新并安装所有更新。确保 eclipse 更新到最新。
- 退出日食。
java -jar lombok.jar
- 确保在弹出的安装程序窗口中 Eclipse 的位置正确,我必须明确指定:
/[some-folder-heirarchy]/Eclipse.app/Contents/Eclipse/eclipse.ini
Thereafter check to see if the updates have made it in eclipse.ini:
此后检查更新是否已在 eclipse.ini 中完成:
-javaagent:/[some_folder-hierarchy]/eclipse-oxygen/Eclipse.app/Contents/Eclipse/lombok.jar
There is only one line that is updated. That is a change from some of the earlier versions of lombok
where a bootclasspath
was also specified and / or the path to lombok.jar
was relative. Now it is an absolute path.
目前只有一个更新行。这是从一些早期版本的更改,lombok
其中bootclasspath
还指定了 a 和/或lombok.jar
相对路径。现在它是一个绝对路径。
Bring up eclipse and you would see Lombok in action.
启动 eclipse,您会看到 Lombok 正在运行。
And do not forget to use the same Lombok
version in your maven
or any other dependency management tool.
并且不要忘记Lombok
在您的maven
或任何其他依赖项管理工具中使用相同的版本。
Edit 1:I also used a different version of Lombok
in the maven POM
from the one that is installed in eclipse
and for the most part, things compiled but there were a few compile errors in eclipse
. Of course, things compiled successfully on the command line with maven
. So if you have project dependencies that force you to use different Lombok versions then be aware of such an eventuality. The crux is to have the same version installed in both eclipse
and in your project's dependency management (maven
etc.).
编辑1:我也用不同的版本Lombok
在maven POM
从安装在一个eclipse
和在大多数情况下,编译的东西,但在有几个编译错误eclipse
。当然,在命令行上使用maven
. 因此,如果您的项目依赖项迫使您使用不同的 Lombok 版本,那么请注意这种可能性。关键是eclipse
在项目的依赖项管理(maven
等)中安装相同的版本。
回答by Krease
For Linux/Ubuntu users who are launching Eclipse from a launcher (a .desktop file) that is locked to your launcher, and your Help --> About dialog doesn't show lombok is installed:
对于从锁定到您的启动器的启动器(一个 .desktop 文件)启动 Eclipse 的 Linux/Ubuntu 用户,并且您的帮助 --> 关于对话框不显示 lombok 已安装:
- Close Eclipse
- Unlock Eclipse from your launcher
- Start Eclipse from the .desktop application
- Verify "Help --> About" indicates lombok is installed (scroll down)
- Lock to your launcher again
- 关闭日食
- 从启动器解锁 Eclipse
- 从 .desktop 应用程序启动 Eclipse
- 验证“帮助 --> 关于”表示 lombok 已安装(向下滚动)
- 再次锁定您的启动器
It seems this works due to some issue with applications 'lock to launcher', and it's the unlock/lock process that fixes it.
这似乎是由于应用程序“锁定到启动器”的一些问题而起作用的,而正是解锁/锁定过程修复了它。
(Thanks to cardamon's comment herethat pointed me to this solution)
回答by Fabiano Costa Leite
Do not use old versions of java.
不要使用旧版本的java。
What happens is that lombok puts the following line in your eclipse.ini:
发生的情况是 lombok 将以下行放入您的 eclipse.ini 中:
-javaagent: lombok.jar
And lombok.jar is in the C:\eclipse\jee-oxygen\eclipse
directory
而 lombok.jar 在C:\eclipse\jee-oxygen\eclipse
目录中
The problem is that the shortcut created by the windows installation looks like this:
问题是windows安装创建的快捷方式是这样的:
Fill in the "Start at" path and it will work:
填写“开始于”路径,它将起作用:
回答by Michael Qin
Solution:
解决方案:
Install lombok 1.16.18 as instructed by lombok website. It's better Eclipse is close during installation.
Make sure Eclipse can start up properly. On the shortcut, change the properties, and fill in the "Start in" path and it will work as noted by Thomas and Fabiano.
Once Eclipse opens, update Maven on the project to solve compilation errors.
Now Lombok latest release works with Eclipse latest release.
按照 lombok 网站的说明安装 lombok 1.16.18。最好在安装过程中关闭 Eclipse。
确保 Eclipse 可以正常启动。在快捷方式上,更改属性,并填写“开始于”路径,它将按照 Thomas 和 Fabiano 的说明工作。
Eclipse 打开后,更新项目上的 Maven 以解决编译错误。
现在 Lombok 最新版本可与 Eclipse 最新版本配合使用。
For reference:
以供参考:
My Eclipse: Oxygen
我的日食:氧气
Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600
My JRE/JDK: 1.8
我的 JRE/JDK:1.8
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
lombok 1.16.18
龙目岛 1.16.18
回答by keichee
I had exactly the same problem with Alex. My eclipse version is
我和亚历克斯有完全相同的问题。我的日食版本是
Version: Oxygen.1a Release (4.7.1a) Build id: 20171005-1200
版本:Oxygen.1a 发布 (4.7.1a) 版本号:20171005-1200
I installed lombok 1.16.18, after checking it was already installed and also javaagent line was added to my eclipse.ini file.
我安装了lombok 1.16.18,在检查它已经安装之后,并且 javaagent 行也被添加到我的 eclipse.ini 文件中。
Every thing was fine except that there are compilation errors where getter is called in the project. It's awkward but I fixed by :
除了在项目中调用 getter 时出现编译错误之外,一切都很好。这很尴尬,但我修复了:
Cleaning project
Building project
Restarting eclipse a few times
清洁工程
建设项目
重启eclipse几次
Nothing else.
没有其他的。
回答by Snehal Masne
Lombok does not work for Eclipse Neon
- You should not just "restart" Eclipse, go to File -> Exit and then open it again. - Don't forget to do a mvn clean just to make sure that you recompiled your classes. - After all this you should also right-click on your project, then Maven -> Update Project
- You should not just "restart" Eclipse, go to File -> Exit and then open it again. - Don't forget to do a mvn clean just to make sure that you recompiled your classes. - After all this you should also right-click on your project, then Maven -> Update Project
回答by Chris C
I had the same problem, however, the original development was done with lombok 1.16.10 and I had installed 1.16.18. When I downloaded and installed 1.16.10 everything worked. I probably needed to do a few cleans and rebuilds to get it to work with .18, but if you're in a hurry, try that.
我有同样的问题,但是,最初的开发是用 lombok 1.16.10 完成的,我已经安装了 1.16.18。当我下载并安装 1.16.10 时,一切正常。我可能需要进行一些清理和重建才能使其与 0.18 一起使用,但如果您赶时间,请尝试一下。
回答by Marc Magon
Quite a few solutions, none solved my problem.
相当多的解决方案,没有一个解决了我的问题。
Eclipse Oxygen 3a April 2018 the installer works fine,
Eclipse Oxygen 3a April 2018 安装程序工作正常,
My issue was running eclipse on a DCEVM JRE. Pointing Eclipse to a non-modified JVM resolved this problem.
我的问题是在 DCEVM JRE 上运行 eclipse。将 Eclipse 指向一个未修改的 JVM 解决了这个问题。