I am aware what Lombok is - it minimizes boilerplate code through the use of some annotations.
And lombok generates the equivalent java code at compile time by using java internals [Ref]. Hence it does not need any explicit plugin or maven/gradle build phase during compile time.
On looking at the pom.xml of a Spring Boot Project, I see below plugins section and am wondering what this exclusion is about.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
CodePudding user response:
The annotations we use, such as @Data, @ToString,@Getter, and @Setter. The "plugin" that actually generates the corresponding code. You need a dependency Lombok so that your compiler can know and resolve the annotations themselves. Annotations need to be imported just like spring data JPA or spring security. But that only makes sure that your compiler / IDE knows that these are valid annotations.
This is similar to java bean validation. You need to import JARS at compile-time, so that all the different validation annotations are known, and can be used within your source code.
You can find more information on this link here
CodePudding user response:
Well,
the problem is following: lombok
is an annotation processor, and the code generated with/by lombok
do not depend on lombok
anymore, in maven
terms that means dependency on lombok
should has provided
scope (in order to not include lombok
jar into target artifact), unfortunately, spring guys have another opinion about dependencies with scope=provided
, please check this conversation: Maven requires plugin version to be specified for the managed dependency spring-boot-configuration-processor
So, your configuration explicitly removes lombok
jar from target artifact.