Lombok: RequiredArgsConstructor not working

According to Documentation, Required arguments are final fields and fields with constraints such as @NonNull.

You need to make username as @NonNull

@NonNull private String username;

And you need to make them final too.


It's also worth noting for future readers that @Data also provides @RequiredArgsConstructor, so using both annotations isn't necessary :)


Did you installed Lombok plugin in IntelliJ?

If not then

File -> Settings -> Plugins: Search for Lombok (CodeStream) version.

Restart the IDE and it should be fixed.

Double Check:

  • You have Lombok library installed using Maven or Gradle.
  • Enabled Annotation Processors from IntelliJ IDE from File -> Settings: Search for Annotation Processors

Tags:

Java

Lombok