首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在JDK上运行Eclipse时显示的编译错误

在JDK上运行Eclipse时显示的编译错误
EN

Stack Overflow用户
提问于 2018-07-09 13:37:02
回答 1查看 207关注 0票数 0

我刚刚发现了Lombok,Spring Suite的奇怪行为,以及我使用JDK代替JRE…运行STS的事实。

这里是我在STS.ini中的当前配置

代码语言:javascript
复制
-startup
plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.700.v20180518-1200
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
-vm
C:\development\applications\Java\jdk-8\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
-Xms40m
-Dosgi.module.lock.timeout=10
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xmx1200m
-javaagent:C:\development\applications\sts-3.9.5.RELEASE\lombok.jar

在IDE中,我得到一个错误的The method […] is undefined for the type […]

然而,IDE似乎知道这个方法确实存在…。

正如我们所看到的,Lombok被正确地安装在STS中。

但是,如果我在JRE中使用以下配置,就不会再有lombok错误,而是POM中的一个问题,要求我使用JDK启动IDE:

代码语言:javascript
复制
-startup
plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.700.v20180518-1200
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
-vm
C:\development\applications\Java\jre-8\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
-Xms40m
-Dosgi.module.lock.timeout=10
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xmx1200m
-javaagent:C:\development\applications\sts-3.9.5.RELEASE\lombok.jar

在使用JDK运行Lombok时,有人知道如何在STS中管理Lombok吗?因为我不想看到任何错误…

编辑01

  • STS 3.9.5版
  • JDK和JRE版本1.8.0_172 64位

为了测试目的,我将VM设置为直接在STS.ini文件中使用。但是,在使用来自PATH环境变量的JDK或JRE时,我确实得到了相同的错误。

编辑02

这里是Insurance bean的代码:

代码语言:javascript
复制
@Getter
@Setter
@Embeddable
public class Insurance implements Serializable {

    private static final long serialVersionUID = 1L;

    @Size(max = 255)
    private String name;

    @Size(max = 255)
    private String number;

    @ApiModelProperty(example = "2018-01-01")
    private LocalDate validityPeriodBegin;

    @ApiModelProperty(example = "2018-12-31")
    private LocalDate validityPeriodEnd;

    @Embedded
    private Address address;
}

编辑03

只要找出答案,但我在IDE中得到的错误并不局限于由Lombok生成的getter/setter。我还从继承…中得到了这种错误。

正如我们所看到的,savedeleteById方法都有标记,但是这些方法是从CrudRepository…继承的。

代码语言:javascript
复制
@Repository
public interface StructureRepository extends CrudRepository<Structure, String> {

    Collection<Structure> findByParentIsNull();

    Collection<Structure> findByParentId(String id);

    Collection<Structure> findByAgentsLogin(String login);
}

我还尝试使用Eclipse的最新版本来代替STS,并且我得到了完全相同的行为。

最后,我尝试使用JDK-10启动IDE,但是没有得到另一个结果…。

这意味着它与隆布克无关,也与STS…无关。可能是Eclipse在使用JDK启动时遇到的问题

EN

回答 1

Stack Overflow用户

发布于 2018-10-23 09:07:32

我现在使用STS-4.0.0.RELEASE代替STS-3.9.5.RELEASE,,使用JDK-11代替JDK-8。结果:不再出现错误…

它可能是在STS-4.0.0.RELEASEJDK-11中修复过的一个bug,因为我在项目配置中没有做太多的更改。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51246936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档