I am struggling for quite a while to make Lombok getter available in two parts of my Spring Boot API. Despite many articles about this error, I haven’t found a suitable solution on the internet for my problem. IntelliJ does recognize all lombok annotations at development time. However, the compilation breaks with the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] xxxxxxxxxxxxxxxxxxxxxxxxxxx/service/AuditorAwareService.java:[19,49] cannot find symbol
symbol: method getId()
location: variable userModel of type xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.UserShortModel
I am using getters, setters and other annotations as well and it works as expected. When I manually implement a getId() getter method in class UserShortModel then no complication error occurs and it works as expected. The error above is the first example where the Lombok getter can’t be found. AuditorAwareService is annotated as a bean in my AppConfiguration class.
@Configuration
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
public class AppConfiguration {
@Bean
public AuditorAware<Long> auditorAware() {
return new AuditorAwareService();
}
}
The second and last example where the same error occurs is when I use a predefined getter in a method in an entity (javax.persistence) class. FirstName and LastName are valid getters in the class IndividualModel. The getter getLabel(), getFirstName(),LastName() throw “cannot find symbol” errors when compiling the code.
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Table(name = "employees")
public static class EmployeeModel extends IndividualModel {
@ManyToOne
@JoinColumn(name="title_id")
private StaticDataModel.StaticDataShortModel title;
@NotNull
@JsonProperty(required = true)
public String getFullName() {
if (this.title != null) {
return this.title.getLabel() + " " + this.getFirstName() + " " + this.getLastName();
}
return this.getFirstName() + " " + this.getLastName();
}
}
I guess the reason is that lombok is too late with creating the getters and setters in the compilation process. I recognized when I build the module before compiling with IntelliJ, all lombok getters are found, even in the app configuration and the entities. However, please note, since I want to use Jenkins the build function of IntelliJ is not a working solution for my project. I also tried to change the annotation process with annotationProcessorPaths in the pom.xml like mentioned here https://newbedev.com/how-to-configure-lombok-with-maven-compiler-plugin. Unfortunately, the same compilation errors occur.
Does anybody can help me to make lombok annotations available in app configurations and entity methods?
Thank you very much!