繁体   English   中英

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

[英]Compilations errors displayed when running Eclipse on a JDK

我刚刚发现Lombok,Spring-Tool-Suite出现了奇怪的行为,并且事实是我使用JDK代替JRE运行STS。

这是我当前在STS.ini配置:

-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:

-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

POM错误,使用JDK启动IDE

使用JDK运行Lombok时,是否有人对如何在STS中管理Lombok有任何想法? 因为我真的不想看到任何错误……


编辑01

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

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


编辑02

这里是Insurance bean的代码:

@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继承的……

@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,但没有得到其他结果。

这意味着它与Lombok无关,也与STS无关...也许是在使用JDK启动Eclipse时与Eclipse有关的问题?

我现在使用STS-4.0.0.RELEASE代替STS-3.9.5.RELEASE ,并且我使用JDK-11代替JDK-8 结果:没有更多错误…

这可能是一个错误,该错误已在STS-4.0.0.RELEASEJDK-11中 修复 ,因为我在项目配置中的更改不多。

暂无
暂无

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

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