使用 Lombok 的 @Slf4j 和 Intellij 构建:找不到符号日志 [英] Building with Lombok's @Slf4j and Intellij: Cannot find symbol log

查看:61
本文介绍了使用 Lombok 的 @Slf4j 和 Intellij 构建:找不到符号日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Maven 项目,它从命令行构建时没有任何问题.但是,当我使用 IntelliJ 构建它时,出现错误:

I have a maven project that builds with no problems from the command line. However, when I build it with IntelliJ, I get the error:

java: FileName.java:89: cannot find symbol
symbol  : variable log

java文件中没有定义或导入的日志,但是有一个

There is no log defined or imported in the java file, but there is a

@Slf4j
final public class FileName {

在定义日志类的类体之前的语句.

statement before the class body which should define the log class.

在项目结构窗口中,类为:

In the project structure window, classes for:

Maven: org.slf4j:jcl-over-slf4j:1.6.1
Maven: org.slf4j:slf4j-api:1.6.6
Maven: org.slf4j:slf4j-log4j12:1.6.6
Maven: org.slf4j:slf4j-simple:1.6.6

列在库下,表示已下载并可用.

are listed under libraries and are indicated as having been downloaded and available.

知道为什么这会通过命令行使用 maven 构建,而不是通过 IntelliJ 构建以及如何解决问题吗?

Any idea why this would build with maven through the command line, but not through IntelliJ and how to resolve the issue?

推荐答案

除了安装了 Lombok 插件,还有确保勾选Enable annotation processing"复选框:

In addition to having Lombok plugin installed, also make sure that the "Enable annotation processing" checkbox is ticked under:

Preferences > Compiler > Annotation Processors

注意:从 IntelliJ 2017 开始,Enable Annotation Processing"复选框已移至:

Note: starting with IntelliJ 2017, the "Enable Annotation Processing" checkbox has moved to:

Settings > Build, Execution, Deployment > Compiler > Annotation Processors

这篇关于使用 Lombok 的 @Slf4j 和 Intellij 构建:找不到符号日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆