我试图在我的项目中使用Lombok,我正在使用IntelliJ IDEA 11开发。

我已经为IDEA安装了第三方插件,它似乎工作正常,因为IDEA可以看到所有自动生成的方法/字段。

我有一个使用Slf4j的类。我这样做了注解

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TestClass
{
    public TestClass()
    {
        log.info("Hello!");
    }
}

但当我建立我的项目编译器吐槽:无法找到符号变量日志。

你能告诉我我错过了什么吗?

更新:原来是RequestFactory注释过程失败了。

input files: {com.zasutki.courierApp.server.TestServlet, com.mine.courierApp.server.model.DatastoreObject}

annotations: [javax.inject.Singleton, javax.inject.Inject, lombok.Getter, lombok.Setter, com.googlecode.objectify.annotation.Id, com.googlecode.objectify.annotation.OnSave]

Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [lombok.Getter, com.googlecode.objectify.annotation.Id, javax.inject.Inject, lombok.Setter, com.googlecode.objectify.annotation.OnSave, javax.inject.Singleton] and returns false.

cannot find symbol variable log

有什么解决办法吗?

更新2:也许这不是读者想听到的,但我最终转向了Scala。


当前回答

我必须禁用刚才添加的@Document注释。我正在转换我的项目使用Mongo而不是Postgres,它以前是工作的,但似乎@文档与Lombok的@Getter冲突

其他回答

To get this working, simply install the "Lombok Plugin" for IntelliJ. You don't need to do anything with enabling "Annotation Processors", as some other commentors have suggested. (I've tested this with the latest version of IntelliJ IDEA, currently 2017.1.2). To install the plugin, go to Settings, then Plugins, then click the "Browse repositories" button, then search for "Lombok", and install the Lombok Plugin. You will be prompted to restart IntelliJ. Afterwards, you should be able to compile from IntelliJ, and you won't receive any more error inspections.

我在更新IDEA到2018.3后就遇到了这个问题。我不得不更新所有现有的插件

如果以上都没有工作,然后尝试更改文件->项目结构->项目->项目语言级别> 8 Lambda,类型注释(非SDK默认8)

这对我很管用。

如果您已勾选以下两个步骤

启用注释:这是在IntelliJ中完成的检查 偏好。 将lombok导入IntelliJ类路径 (首选项->插件)

仍然得到错误,然后请检查编译器-如果它是JAVAC或ECLIPSE。

您可以在“首选项->构建,执行,部署->编译器-> Java编译器”中查看编译器。

将Use编译器更改为Javac(如果它是Eclipse)。这对我来说很管用。

我必须禁用刚才添加的@Document注释。我正在转换我的项目使用Mongo而不是Postgres,它以前是工作的,但似乎@文档与Lombok的@Getter冲突