Intellij 不识别 Java Spring-Boot 的 lombok setter

Intellij does not recognize lombok setters for Java Spring-Boot

我在 Ubuntu(运行时版本 11.0.5)上使用 IntelliJ,目前我正在构建一个 Spring-Boot 应用程序。我正在使用 lombok 插件来自动为我的实体生成 getterssetters。这是我的代码目前的样子:


@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;

}

尽管当我尝试使用来自另一个 class 的 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;
    }

在这一点上,我需要提到吸气剂不会发生同样的事情。 Lombok插件已激活,IntelliJ上已激活注解处理:

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

你的id是finallombok只会为可以设置的字段生成setter。