简体   繁体   English

无法解决Maven项目Eclipse光子中的错误

[英]Unable to resolve errors in maven project eclipse photon

I have imported an existing manven project into my eclipse new workspace which I downloaded from github. 我已经将现有的manven项目导入到我从github下载的eclipse新工作区中。 On maven install I get a BUILD SUCCESS but the red cross on the project never goes. 在maven安装中,我获得了BUILD SUCCESS但项目上的红十字从未消失。 This issue has been raised previously : link1 , link2 以前已经提出过此问题: link1link2

Most of the solutions tell about update project and any number times I do update project, It doesn't solve the problem. 大多数解决方案都讲述更新项目,而我执行更新项目的次数不胜枚举,但这并不能解决问题。

The other solution is about having lombok plug-in because I noticed that many of the getter and setter methods are causing problems(absent). 另一个解决方案是关于使用lombok插件,因为我注意到许多getter和setter方法都引起了问题(缺少)。 The lombok plug-in is to auto-generate them....I have it in my pom.xml but still the problem persists. lombok插件是自动生成它们的...。我在pom.xml中拥有它,但问题仍然存在。 In fact the problems tab shows a 100 errors like the samples below: 实际上,问题标签显示了100个错误,例如以下示例:

__ cannot be resolved to a type __无法解析为类型

The blank final field API_KEY may not have been initialized 空白的最终字段API_KEY可能尚未初始化

The constructor APNSService(ApnsService) is undefined 构造函数APNSService(ApnsService)未定义

How to solve this issue? 如何解决这个问题?

Any help is appreciated. 任何帮助表示赞赏。

Note: I am running the maven project on jdk1.8. 注意:我正在jdk1.8上运行maven项目。

You also must have the lombok plugin installed in Eclipse. 您还必须在Eclipse中安装lombok插件。 (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. (请注意,这与项目依赖项中存在的lombok有所不同;您需要两者。)此外,Eclipse中安装的版本应该与pom.xml中的版本相同。 Otherwise strange compilation issues may occur, like code compiling in Eclipse but not in maven, or vice versa. 否则,可能会发生奇怪的编译问题,例如在Eclipse中进行代码编译,而在maven中则不会,反之亦然。

Installation instructions for Eclipse can be found here . Eclipse的安装说明可以在这里找到。

UPDATE: Check the "About Eclipse" dialog after the installation and an Eclipse restart. 更新:安装并重新启动Eclipse之后,请检查“关于Eclipse”对话框。 It must contain some text like " Lombok v1.18.3 "Edgy Guinea Pig" is installed. ". 它必须包含一些文字,例如“ Lombok v1.18.3“ Edgy Guinea Pig”已安装 If that is not the case, the lombok plugin is not installed correctly. 如果不是这种情况,则说明lombok插件未正确安装。

If the installation was not successful, you should try installing lombok to a clean Eclipse installation (even before adding any projects). 如果安装不成功,则应尝试将lombok安装到干净的Eclipse安装中(甚至在添加任何项目之前)。 You could also try Eclipse Oxygen instead of Photon (there are sporadic reports of problems with Photon; however, there seems to be no general issue in combination with Photon). 您也可以尝试使用Eclipse Oxygen代替Photon(有零星的 关于 Photon问题的报告 ;但是,与Photon结合似乎没有一般性问题)。

Explanation: Eclipse uses its own compiler (different from javac, which maven uses). 说明: Eclipse使用自己的编译器(与maven使用的javac不同)。 Therefore, lombok also has to hook into the Eclipse compilation process, and therefore, Eclipse needs that lombok plugin. 因此,lombok还必须加入Eclipse编译过程,因此Eclipse需要该lombok插件。

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

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