[英]Intellij does not recognize lombok setters for Java Spring-Boot
I am using IntelliJ on Ubuntu (runtime version 11.0.5) and currently I am building a Spring-Boot
application.我在 Ubuntu(运行时版本 11.0.5)上使用 IntelliJ,目前我正在构建一个
Spring-Boot
应用程序。 I am using the lombok
plugin in order to generate getters
and setters
for my entity automatically.我正在使用
lombok
插件来自动为我的实体生成getters
和setters
。 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;
}
Despite that when I try to use setters from another class, spring-boot doesnt not recognize them:尽管如此,当我尝试使用另一个类的 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;
}
On that note, I need to mention that same thing does not happen for getters.关于这一点,我需要提到吸气剂不会发生同样的事情。 Lombok plug-in is activated and annotation processing is activated on IntelliJ:
Lombok 插件激活,在 IntelliJ 上激活注解处理:
Does anyone understand why this happens and how I could fix it?有谁明白为什么会发生这种情况以及我如何解决它? I appreciate any help you can provide
感谢您提供的任何帮助
您的 id 是final
lombok 只会为可以设置的字段生成设置器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.