簡體   English   中英

Lombok 的 IntelliJ IDEA 編譯錯誤

[英]IntelliJ IDEA compilation error with Lombok

我有一個使用集成開發環境 IntelliJ IDEA 的帶有 Lombok 的 SpringBoot 項目,帶有這個 object:

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
@Entity
@Table(name = "t_user_role")
public class UserRole implements Serializable {



    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonIgnore
    private Long id;
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "user_id")
    @JsonIgnore
    private User user;
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "role_id")
    private Role role;


}

還有這個 object:

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
@Entity
@Table(name="t_user")
public class User implements Serializable, UserDetails {

..

    @Override
    @JsonIgnore
    public Collection<? extends GrantedAuthority> getAuthorities() {
        Set<GrantedAuthority> authorities = new HashSet<>();
        userRoles.forEach(ur -> authorities.add(new Authority(ur.getRole().getName())));
        return authorities;
    }

..
}

但我有一個編譯錯誤:

在此處輸入圖像描述

但是當我使用 maven 編譯項目時,一切都很好

只需安裝 lombok 插件並重新啟動 IDEA,希望能正常工作。 您可以按照以下步驟操作:

  1. Go 到文件 > 設置 > 插件
  2. 單擊瀏覽存儲庫
  3. 搜索龍目島
  4. 點擊安裝插件
  5. 重啟 IntelliJ IDEA
  6. 干凈地構建項目
  7. 如果還是不行,go 到文件 | 使緩存無效/重新啟動

確保啟用注釋處理,並安裝 intelij lombok 插件

看到這個在此處輸入鏈接描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM