Reputation: 1517
I have created jar file which contains Hibernate entities along with DTOs. Every DTO has following annotations:
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
I build this library using Gradle and use it in the Spring boot projects. But the problem is all the above annotations are not working. No getter/setter, constructors etc are available in Spring boot project.
this is my entry in build.gradle file in Spring boot projects
implementation files('lib/xxx-entities-1.0.jar')
Annotation processing is enabled in both projects, Lombok is added in both. Still the problem occurs. I am using IntelliJ Idea.
Upvotes: 1
Views: 848
Reputation: 4440
First of all you should inspect compiled classes in your jar containing entities and DTOs. If the getters and setters are not there along with the rest of expected Lombok-generated code then check whether annotation processor is applied when the sources are compiled.
As soon as you use Gradle I'd suggest to add this line into dependencies
section of your build file (for the module where the entities and DTOs are kept):
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
So your build.gradle
(for Gradle 7.2) should look like:
ext {
lombokVersion = '1.18.22'
}
plugins {
id 'java'
}
dependencies {
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
}
Upvotes: 2