Java Lombok 不适用于 Eclipse Neon
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42444457/
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 does not work for Eclipse Neon
提问by Alex
I downloaded lombok.jar (lombok-1.16.14.jar) put it into my Downloads. Then I clicked on this jar, the execution correctly identifies the Eclipse instances on my MacOS and then I selected the instance I want. Lombok is also specified in the pom.xml org.projectlombok lombok 1.16.14 provided
我下载了 lombok.jar (lombok-1.16.14.jar) 并将其放入我的下载中。然后我点击这个 jar,执行正确地识别了我的 MacOS 上的 Eclipse 实例,然后我选择了我想要的实例。Lombok也在提供的pom.xml org.projectlombok lombok 1.16.14中指定
In eclipse.ini I got the addition: -javaagent:../Eclipse/lombok.jar
在 eclipse.ini 我得到了补充: -javaagent:../Eclipse/lombok.jar
lombok.jar was added to the same directory as eclise.ini /Applications/Eclipse.app/Contents/Eclipse
lombok.jar 被添加到与 eclise.ini /Applications/Eclipse.app/Contents/Eclipse 相同的目录中
I am still getting setter/getter errors in Eclipse Problems despite that my mvn
build works fine.
尽管我的mvn
构建工作正常,但我仍然在 Eclipse 问题中遇到 setter/getter 错误。
The code for a User:
用户代码:
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(UserListener.class)
public class User implements Serializable, UserDetails {
...
The error:
错误:
The method getRole() is undefined for the type User
采纳答案by Alex
For me, downloading the latest Eclipse Neon, i.e. Neon 3, fixed the problem
对我来说,下载最新的 Eclipse Neon,即 Neon 3,解决了这个问题
回答by imTachu
Since you have already added the .jar to your lib
folder, then go to the lib
and execute java -jar lombok-1.16.4.jar
, you'll see a wizard, specify the location of your eclipse.ini
, after you are done with this your eclipse.ini
file should look like this:
由于您已经将 .jar 添加到您的lib
文件夹中,然后转到lib
并执行java -jar lombok-1.16.4.jar
,您将看到一个向导,指定您的 .jar的位置,eclipse.ini
完成此操作后,您的eclipse.ini
文件应如下所示:
-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar
For me this just worked fine but I found in other answers that:
对我来说,这很好用,但我在其他答案中发现:
- You should not just"restart" Eclipse, go to
File -> Exit
and then open it again. taken from here - Don't forget to do a
mvn clean
just to make sure that you recompiled your classes. taken from here - After all this you should also right-click on your project, then
Maven -> Update Project
taken from here
回答by mike
try @Data annotation for the class.
尝试为类添加 @Data 注释。
public @Data class user{
\do stuff
}
回答by SkyWalker
Antoniolazarohas given a solution for Eclipse Neon issue on MacOS
Antoniolazaro为 MacOS 上的 Eclipse Neon 问题提供了解决方案
When I put the complete path, it works on Mac Os.
当我输入完整路径时,它可以在 Mac Os 上运行。
-javaagent:/Applications/Eclipse.app/Contents/Eclipse/lombok.jar
Resource Link:
资源链接:
And the lombok project owner rzwitserloothas given 3 suggestions for checking
而lombok项目负责人rzwitserloot给出了3个检查建议
- Can you give us the complete path, from root, of your eclipse install? Starting with 1.16.14, the installer should still find eclipse even with the funky paths that the OOM installer comes up with. I have no idea why the installer isn't finding your eclipse automatically, here. I can't reproduce this on my mac.
- The lombok uninstaller has the same
'find eclipses'
capability as the installer.Mac doesn't have a registry and we aren't going to dump a bunch of crud in your homedir just to keep track of where we installed your lombok;
we like it that way: No cruft. So, that part (that the uninstaller can't find a custom-install location and requires you to again specify it) is not a bug. - You still have to add
lombok.jar
to your project as a dependency same as any other third party dependency (something like guava, for example). It's not clear from your problem description if you actually did that.
- 你能从根目录给我们你的 eclipse 安装的完整路径吗?从 1.16.14 开始,即使使用 OOM 安装程序提供的时髦路径,安装程序仍应找到 eclipse。我不知道为什么安装程序没有在这里自动找到你的 eclipse。我无法在我的 mac 上重现这个。
- lombok 卸载
'find eclipses'
程序与安装程序具有相同的功能。Mac doesn't have a registry and we aren't going to dump a bunch of crud in your homedir just to keep track of where we installed your lombok;
我们喜欢这样:没有多余的东西。因此,那部分(卸载程序找不到自定义安装位置并要求您再次指定它)不是错误。 - 您仍然必须将
lombok.jar
作为与任何其他第三方依赖项(例如番石榴之类的东西)相同的依赖项添加到您的项目中。从您的问题描述中不清楚您是否真的这样做了。
Resource Link:
资源链接:
回答by Yu Jiaao
There is a manual way to install lombok
under eclipse, I do not checked it, but it maybe helps you -
lombok
eclipse下有手动安装的方法,我没查过,但也许对你有帮助——
copy
lombok.jar
to where your eclipse folder where is theeclipse.ini
open
eclipse.ini
,put at end the below two lines below and save it-Xbootclasspath/a:lombok.jar -javaagent:lombok.jar
restart
eclipse
.
复制
lombok.jar
到你的eclipse文件夹在哪里eclipse.ini
打开
eclipse.ini
,把下面两行放在最后并保存-Xbootclasspath/a:lombok.jar -javaagent:lombok.jar
重新启动
eclipse
。
回答by rafambbr
My environment is:
我的环境是:
IDE: Version: Neon.3 Release (4.6.3)
OS: Ubuntu 16.4
It works for me when i do this steps below:
当我执行以下步骤时,它对我有用:
1. copy `lombok.jar` to where your eclipse folder where is the `eclipse.ini` ;
2. open `eclipse.ini`,put at end the two lines below with full lombok path and save it:
-Xbootclasspath/a:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
-javaagent:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
3. restart `eclipse` in command line (when i try run with exist link in launcher it's not work)
4. rebuild your projects
回答by mam10eks
I had the problem, that the link, which I used to start eclipse, didnt respect the eclipse.ini file.
我遇到了问题,我用来启动 eclipse 的链接不尊重 eclipse.ini 文件。
My environment is:
我的环境是:
IDE: Version: Neon.0 Release (4.6.0)
OS: Ubuntu 16.04.2 LTS
The installation routine java -jar lombok-1.16.16.jar
works quite well. I.e. it adds the reasonable line -javaagent:<ABSOLUTE_PATH_TO_ECLIPSE_INSTALLATION>/lombok.jar
to the eclipse.ini
.
安装程序java -jar lombok-1.16.16.jar
运行良好。即它将合理的行添加-javaagent:<ABSOLUTE_PATH_TO_ECLIPSE_INSTALLATION>/lombok.jar
到eclipse.ini
.
But if I start eclipse by using my desktop-shortcut, it starts without lombok (checked by looking at "Help"->"About Eclipse").
If I start eclipse by executing the executable eclipse
next to the eclipse.ini
file, lombok launches like a charm.
但是,如果我使用我的桌面快捷方式启动 eclipse ,它会在没有 lombok 的情况下启动(通过查看“帮助”->“关于 Eclipse”进行检查)。如果我通过执行文件eclipse
旁边的可执行文件来启动 eclipse eclipse.ini
,lombok 会像魅力一样启动。
Hence I checked my desktop shortcut (e.g. ~/.local/share/applications/eclipse.desktop
) and indeed, it started eclipse without reflecting the eclipse.ini
.
Instead it uses something like /usr/bin/java -jar org.eclipse.equinox.launcher.jar ...
to start eclipse.
因此,我检查了我的桌面快捷方式(例如~/.local/share/applications/eclipse.desktop
),确实,它在没有反映eclipse.ini
. 相反,它使用类似/usr/bin/java -jar org.eclipse.equinox.launcher.jar ...
启动 eclipse 的东西。
So the solution was to replace the old Exec
line in the desktop shortcut by:
所以解决方案是通过以下方式替换Exec
桌面快捷方式中的旧行:
Exec=/opt/eclipse/neon/eclipse
where /opt/eclipse/neon/
is the place where I have installed eclipse.
这里/opt/eclipse/neon/
是我已经安装了Eclipse的地方。
回答by avi.elkharrat
As far as I am concerned, I use a "Chocolatey" distribution of Eclipse on Windows.
就我而言,我在 Windows 上使用 Eclipse 的“Chocolatey”发行版。
It does not change much. But for those of you who are not admin of their desktop, it might be a hassle, because Chocolatey installs softwares in C:\ProgramData\...
which is an "admin" directory.
它没有太大变化。但是对于那些不是桌面管理员的人来说,这可能会很麻烦,因为 Chocolatey 安装的软件C:\ProgramData\...
是一个“管理员”目录。
In other words, you may need to modify your shortcut's property "start in" which will not be possible unless you are admin of your desktop.
换句话说,您可能需要修改快捷方式的“开始于”属性,除非您是桌面管理员,否则这是不可能的。
The trick that worked for me here was to create a new shortcut, which has the correct "start in" property to start eclipse in the directory where the eclipse.ini is...
在这里对我有用的技巧是创建一个新的快捷方式,它具有正确的“开始于”属性以在 eclipse.ini 所在的目录中启动 eclipse...
Then recompile using eclipse, then work on your project a bit until eclipse realizes that lombok was installed...
然后使用 eclipse 重新编译,然后对您的项目进行一些工作,直到 eclipse 意识到 lombok 已安装...
Cheers
干杯
回答by loc huynh
After installing lombok, you need to copy lombok.jar into your project or add dependency in maven configuration xml file
安装 lombok 后,需要将 lombok.jar 复制到您的项目中或在 maven 配置 xml 文件中添加依赖项
回答by Somnath Singh
exit the eclipse and then go to the eclipse directory and open eclipse.ini
and add -clean
on a top and rerun the eclipse. hope your problem is solved.
退出 eclipse,然后转到 eclipse 目录并打开eclipse.ini
并添加-clean
一个顶部并重新运行 eclipse。希望你的问题得到解决。