Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There's Lombok annotation @Slf4j which won't work

I need your help. I have a problem with Lombock annotation @Slf4j. When I try to use it I don't have ability to use its functionality: enter image description here

There's my build.gradle file: enter image description here

I've already installed Lombock into my IntelliJ Idea and enabled Annotating processing, but it haven't got me resul yet. Can you make some advice? I would be very grateful!

like image 698
Jonas_Astley Avatar asked Oct 28 '25 13:10

Jonas_Astley


1 Answers

Taking a wild stab here, but lombok doesn't include slf4j. It really can't do that1. All features in the extern packages work like this, and it is why the lombok.extern package layer exists: To show you that it's a lombok feature that makes some non-core ('external') dependency work nicer, not that the lombok feature includes this dependency or replaces it.

Thus, all you would need to fix this is to add slf4j to your dependencies:

compile 'org.slf4j:slf4j:1.7.31'

omr something along those lines. Note that SLF4j also needs runtime configuration (slf4j itself is just a 'frontend' that lets you write log statements that go to whereever your configuration says they go at runtime. This 'configuration' includes the code to actually do stuff with these logs. Slf4j tutorials will cover all this.

[1] Adding the deps automatically is not really possible; lombok ships with a number of features that are specifically to make some library / framework easier to use, we (DISCLAIMER: I do quite a bit of work on lombok) can't ship them all of those as deps of lombok, and we haven't (and probably would never) try to hack into your build system to make some sort of semi-dependent system where we detect you use e.g. @Slf4j and somehow make your build system include it only then.

like image 188
rzwitserloot Avatar answered Oct 30 '25 01:10

rzwitserloot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!