Lombok是否可以与Kotlin一起使用? [英] Is it possible to use Lombok with Kotlin?
问题描述
我有一个Kotlin Gradle项目.我将Lombok添加为依赖项,并使用kapt注册了它
I have a Kotlin Gradle project. I added Lombok as a dependency and also registred it with kapt
compileOnly("org.projectlombok:lombok:$lombokVersion")
kapt("org.projectlombok:lombok:$lombokVersion")
我只想使用@Slf4j
注释来自动生成log
.它适用于Java类,但不适用于Kotlin类.
I would like to use just @Slf4j
anotation for automatic log
generation. It works for Java classes but not for the Kotlin ones.
到目前为止,是否有可能同时使用Kotling和Lombok?
Is using Kotling and Lombok together even possible as of now ?
添加更多详细信息
如果我用@Slf4j
注释Kotlin类并在其中使用log
,我会得到
If I annotate a Kotlin classs with @Slf4j
and use log
inside it I get
未解决的参考:日志
Unresolved reference: log
显然没有应用注释处理.
Evidently no annotation processing is applied.
推荐答案
您不能使用注释@Slf4j
,而是在所需的类中手动创建其对象.
You cannot use annotation @Slf4j
, but manually create its object in the class required.
引用 https://www.reddit.com/r/Kotlin /comments/8gbiul/slf4j_loggers_in_3_ways/
这篇关于Lombok是否可以与Kotlin一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!