龙目岛不在Netbeans项目中工作 [英] Lombok not working in a Netbeans project
问题描述
我想在项目中使用Lombok以使用@Getter和@Setter.
I want to use Lombok in a project to use @Getter and @Setter.
我包括使用Maven:
I included using Maven:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.12.6</version>
<scope>provided</scope>
</dependency>
对于Netbeans,导入是可以的:
Import is OK for Netbeans:
import lombok.Getter;
import lombok.Setter;
但是自动设置器和吸气器不起作用(没有自动完成/找不到符号...").
But auto setters and getters don't work (no autocompletion / "cannot find symbol ...").
奇怪的是,对于另一个项目,我的工作正常!但是我看不出它们之间的差异.
Strange thing is that for another project I have it's working fine! But I can't figure the differences.
我测试过:
-
更改lombok版本(甚至最后一个):对于任何版本,导入都不再起作用
change the lombok version (even the last): for any version, the import don't work anymore
使用Maven构建项目:没关系!
build the project with Maven: it's OK!
使用Eclipse:可以! (但我是唯一决定的人)
use Eclipse: it's OK! (but I am the only one to decide unfortunately)
=>所以我确定这是与Netbeans相关的问题
=> so I'm sure this is a Netbeans related problem
- 启用注释处理,如我在教程中所见=>我的项目属性中没有这样的选项
有什么主意吗?
推荐答案
在使用Apache Maven 3.5.4的Netbeans 8.2中,使用Lombok 1.16.16 .
In Netbeans 8.2 using Apache Maven 3.5.4 use Lombok 1.18.4 or much older 1.16.16.
在Netbeans 10.0/9.0中,使用 Apache Maven 3.5.4使用Lombok 1.18.4 ,旧版本的Lombok是保存时编译时为"nofollow noreferrer">错误. /em>
In Netbeans 10.0/9.0 using Apache Maven 3.5.4 use Lombok 1.18.4, older versions of Lombok are really buggy when Compile On Save is used in Netbeans 10.0/9.0
我将Lombok更新为新的版本
I updated Lombok to a new version
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
<version>1.18.8</version> <!--1.18.8 for Netbeans 9/10 OR 1.16.16 for Netbeans 8 with Java 8 -->
</dependency>
NB
- 对于maven-compiler-plugin,删除所有要做的注解 在Maven-compiler-plugin中使用Lombok
- 删除所有Lombok Maven插件
- For maven-compiler-plugin, remove any annotationProcessorPaths to do with Lombok in the maven-compiler-plugin
- Remove any Lombok maven plugins
这不是必需的,因为Maven和Netbeans开箱即用.您只需要在Maven中使用正确的Lombok依赖项即可.
This is not needed, as Maven and Netbeans does this out of the box. You only need the right Lombok dependency in Maven.
这篇关于龙目岛不在Netbeans项目中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!