我刚刚发现了Lombok,Spring 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

在使用JDK运行Lombok时,有人知道如何在STS中管理Lombok吗?因为我不想看到任何错误…
编辑01
为了测试目的,我将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。我还从继承…中得到了这种错误。

正如我们所看到的,save和deleteById方法都有标记,但是这些方法是从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,但是没有得到另一个结果…。
这意味着它与隆布克无关,也与STS…无关。可能是Eclipse在使用JDK启动时遇到的问题
发布于 2018-10-23 09:07:32
我现在使用STS-4.0.0.RELEASE代替STS-3.9.5.RELEASE,,使用JDK-11代替JDK-8。结果:不再出现错误…
它可能是在STS-4.0.0.RELEASE或JDK-11中修复过的一个bug,因为我在项目配置中没有做太多的更改。
https://stackoverflow.com/questions/51246936
复制相似问题