Skip to content
Advertisement

How to generate annotations and use lombok with javapoet?

Is there any way (and any sense) to use Lombok when I am using javapoet?
Here is example:

JavaScript

When I am trying to add Lombok annotation (like that -> Data.class”) I get the following error:

JavaScript

Advertisement

Answer

Probably because Lombok is usually given provided scope – you ordinarily don’t want it on the classpath, because it’s supposed to be processed and removed at compile-time.

JavaScript

Remove the <scope>provided</scope> line, or change it to compile. Both are equivalent, since compile is the default.

I would personally explicitly use compile and maybe even add a comment explaining why you’re not using provided, since a casual reader might think it’s a mistake otherwise, and maybe try to change it to provided again.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement