Intellij无法识别Java Spring-Boot的lombok设置程序

I am using IntelliJ on Ubuntu (runtime version 11.0.5) and currently I am building a Spring-Boot application. I am using the lombok plugin in order to generate getters and setters for my entity automatically. This is how my code looks like currently:


@Getter
@Setter
@RequiredArgsConstructor
@Document
public class Experts {

    @Id
    private final String id;


    private final String name;
    private final String desc;

    @Enumerated(EnumType.STRING)
    private final Availability availability;

    @Enumerated(EnumType.STRING)
    private final Language language;

}

尽管如此,当我尝试使用另一个类中的setter时,spring-boot仍无法识别它们:


@Service
@RequiredArgsConstructor
public class ExpertsServiceImpl implements ExpertsService{

    private final ExpertRepository repository;

    @Override
    public Experts updateExpert(Experts expert, String id) {
        Experts updated = findExpertById(id);
        if(updated == null) {
            throw new ExpertNotFoundException(id);
        }

        updated.setId(expert.getId()); // here is shows: Cannot resolve method 'setId' in 'Experts'
        repository.save(updated);
        return updated;
    }

关于这一点,我需要提及的是,吸气剂不会发生相同的事情。在IntelliJ上激活了Lombok插件并激活了注释处理:

enter image description here

有谁知道为什么会发生这种情况以及如何解决?感谢您能提供的任何帮助

评论
  • Peter
    Peter 回复

    Your id is final lombok will only generate setters for fields that can be set.