Is it possible to use Lombok with Kotlin?

坚强是说给别人听的谎言 提交于 2019-12-04 22:21:40

Lombok does not run on your source code, but on the AST. Anyway, it is an annotation processor that is run at compile-time by the Java compiler. The Kotlin compiler does not use these annotation processors. See also the answer https://stackoverflow.com/a/35530223/2621917 straight from the horse’s mouth.

You cannot use annotation @Slf4j, but manually create its object in the class required.

Refer https://www.reddit.com/r/Kotlin/comments/8gbiul/slf4j_loggers_in_3_ways/

It's not supported and, by the looks of things, it isn't going to be.

If all you want to use Lombok for is @Slf4j, then I'd suggest using kotlin-logging instead: https://github.com/MicroUtils/kotlin-logging

I can't see how it would work without additional support from the lombok team. Lombok is based on annotation processing so it runs during compilation time and runs on your source code, so I guess it assumes Java's syntax.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!