Eclipse Lombok批注未编译...为什么? [英] Eclipse Lombok annotations not compiled... Why?

查看:169
本文介绍了Eclipse Lombok批注未编译...为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有问题. 这是一个Spring CRUD RestFul API,它公开了正在提供Json数据的服务. 我使用JDK-7,Eclipse-Neon和Maven进行编码,构建,并将项目部署到JBossEAP 6.4服务器中. 一切正常,服务正确响应.

I have a problem with my project. It is an Spring CRUD RestFul API that expose services witch are providing Json datas. I use JDK-7, Eclipse-Neon and Maven to code, build and the project is deployed into a JBossEAP 6.4 server. Every thing is working well, the services are responding correctly.

因此,我决定添加Lombok,以减少锅炉代码并提高代码的可读性.顺便说一下,我之前在另一个项目上使用了Lombok,并且运行良好.

So I decide to add Lombok, to reduce the boiler code and improve the readability of the code. By the way I used Lombok on an another project before and is worked fine.

这是我的问题,包括龙目岛之后: -当我使用Maven(mvn全新安装)试听时,一切进展顺利,项目部署和工作都非常顺利. -当项目由Eclipse构建时,Lombok批注(即:@Data等)不包含在* .class中.因此,Eclipse部署的耳朵可以正常工作,但所有实体都没有任何吸气剂/吸气剂,依此类推.

Here is my problem, after including Lombok : - When I make an ear using Maven (mvn clean install), everything is going well, the project deploy and work perfectly fine. - When the project is built by Eclipse, the Lombok annotations (i.e.:@Data, etc) aren't included into the *.class. Consequently the ear deployed by Eclipse work fine BUT all the entity haven't any getter / setter and so on.

我知道Eclipse已正确配置,因为我的代码中没有与Lombok相关的任何警告,eclipse的大纲视图向我显示了生成的方法.

I know Eclipse is correctly configured because I haven't any warning associated to Lombok on my code, the outline view of eclipse show me generated methods.

有人对这种问题有想法吗?

Does anyone have a idea about this kind of problem?

推荐答案

您还必须在Eclipse中安装了lombok插件. (请注意,这与项目依赖项中存在的lombok有所不同;您需要两者.)此外,Eclipse 中安装的版本应该与pom.xml中的版本相同.否则,可能会发生奇怪的编译问题,例如某些注释的代码不是在Eclipse中生成的,而是在maven中生成的,反之亦然.

You also must have the lombok plugin installed in Eclipse. (Note that this is something different from lombok being present in the project dependencies; you need both.) Furthermore, the version installed in Eclipse should be the same version that you have in your pom.xml. Otherwise strange compilation issues may occur, like code for some annotations not getting generated in Eclipse but in maven, or vice versa.

可以在此处找到Eclipse的安装说明.

Installation instructions for Eclipse can be found here.

在安装并重新启动Eclipse之后,检查关于Eclipse"对话框.它必须包含一些文本,例如" Lombok v1.18.3"Edgy豚鼠"已安装..如果不是这种情况,则说明lombok插件安装不正确.

Check the "About Eclipse" dialog after the installation and an Eclipse restart. It must contain some text like "Lombok v1.18.3 "Edgy Guinea Pig" is installed.". If that is not the case, the lombok plugin is not installed correctly.

如果安装不成功,则应尝试将lombok安装到干净的Eclipse安装中(甚至在添加任何项目之前).

If the installation was not successful, you should try installing lombok to a clean Eclipse installation (even before adding any projects).

说明: Eclipse使用自己的编译器(与maven使用的javac不同).因此,lombok还必须加入Eclipse编译过程,因此Eclipse需要该lombok插件.

Explanation: Eclipse uses its own compiler (different from javac, which maven uses). Therefore, lombok also has to hook into the Eclipse compilation process, and therefore, Eclipse needs that lombok plugin.

还请注意,已编译的类文件中不应存在Lombok注释,因为在生成替换代码时Lombok注释处理器会删除它们.

Also note that Lombok annotation should never be present in the compiled class file, because the Lombok annotation processor removes them when generating the replacement code.

这篇关于Eclipse Lombok批注未编译...为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆