Lombok: RequiredArgsConstructor not working

后端 未结 5 1151
逝去的感伤
逝去的感伤 2021-01-01 12:49

It seems that @RequiredArgsConstructor not working in the code below. Why is it?

import java.io.Serializable;

import lombok.Data;
import lombok         


        
5条回答
  •  再見小時候
    2021-01-01 13:50

    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.

提交回复
热议问题