简体   繁体   English

Lombok 的 IntelliJ IDEA 编译错误

[英]IntelliJ IDEA compilation error with Lombok

I have a SpringBoot project with Lombok using the integrated development environment IntelliJ IDEA, with this object:我有一个使用集成开发环境 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;


}

and also this object:还有这个 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;
    }

..
}

but I have a compilation error:但我有一个编译错误:

在此处输入图像描述

but when I compile the project using maven everything is fine但是当我使用 maven 编译项目时,一切都很好

Just install lombok plugin and restart the IDEA, hope will work.只需安装 lombok 插件并重新启动 IDEA,希望能正常工作。 You can follow the steps below:您可以按照以下步骤操作:

  1. Go to File > Settings > Plugins Go 到文件 > 设置 > 插件
  2. Click on Browse repositories单击浏览存储库
  3. Search Lombok搜索龙目岛
  4. Click on Install plugin点击安装插件
  5. Restart IntelliJ IDEA重启 IntelliJ IDEA
  6. clean build the project干净地构建项目
  7. If still doesn't work, go to File |如果还是不行,go 到文件 | Invalidate Caches/Restart使缓存无效/重新启动

Be sure you enable annotation processing, and install intelij lombok plugin确保启用注释处理,并安装 intelij lombok 插件

See this one enter link description here看到这个在此处输入链接描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM