It seems that @RequiredArgsConstructor
not working in the code below. Why is it?
import java.io.Serializable;
import lombok.Data;
import lombok
It's also worth noting for future readers that @Data also provides @RequiredArgsConstructor, so using both annotations isn't necessary :)
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.
Did you installed Lombok plugin in intellij ?
If not then
File -> Settings -> Plusings: Search for Lombok (CodeStream) version.
Restart the IDE and it should be fixed.
Double Check:
Annotation Processors
from intellij IDE from File -> Settings: Search for Annotation Processors
Try changing project/module JDK to 1.8.
Project Structure -> Project Settings->Project SDK and Project Language Level
The argument fields for @RequiredArgsConstructor annotation has to be final
. So this fix will work:
private final String username;
The IDE IntelliJ makes the variable grey (inactive status) when final
keyword missed, which is very helpful to detect this kind of mistake.