Why did lombok suddenly stop working on my project?

Viewed 161

I've been refactoring a Spring3-based project to Spring5 and hit a bizarre situation where suddenly all of the lombok-related code was not getting generated. e.g.

@Slf4j
public class MyClass {
...
  log.info("something");

would throw up this error

cannot find symbol
  symbol: variable log
  location: MyClass

IntelliJ IDEA also started failing to do just about anything correctly. Maven refreshes, cleans, or standard IDE builds would just throw errors on lines where there was clearly nothing wrong.

As I had recently done a large-scale structured find and replace and multiple refactoring operations, I couldn't tell what I'd done which had broken it.

1 Answers

While IntelliJ was simply falling over and being unable to compile any of the code, a command line compilation with Maven showed this error:

[ERROR] /C:/dev/source/...../MySecuredWebService.java:[83,5] org.springframework.security.access.prepost.PreAuthorize is not a repeatable annotation type

It turns out I had accidentally annotated a method twice with @PreAuthorize. This prevented both Spring and lombok from doing any annotation processing, and thus also broke IntelliJ. Simply removing the errant annotation fixed everything again.

Related