[英]Intellij does not recognize lombok setters for Java Spring-Boot
我在 Ubuntu(運行時版本 11.0.5)上使用 IntelliJ,目前我正在構建一個Spring-Boot
應用程序。 我正在使用lombok
插件來自動為我的實體生成getters
和setters
。 這是我的代碼目前的樣子:
@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;
}
關於這一點,我需要提到吸氣劑不會發生同樣的事情。 Lombok 插件激活,在 IntelliJ 上激活注解處理:
有誰明白為什么會發生這種情況以及我如何解決它? 感謝您提供的任何幫助
您的 id 是final
lombok 只會為可以設置的字段生成設置器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.