【问题标题】:IntelliJ IDEA compilation error with LombokLombok 的 IntelliJ IDEA 编译错误
【发布时间】:2019-11-01 13:29:01
【问题描述】:

我有一个使用集成开发环境 IntelliJ IDEA 的带有 Lombok 的 SpringBoot 项目,带有这个对象:

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


}

还有这个对象:

@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 编译项目时,一切都很好

【问题讨论】:

  • 安装插件

标签: java spring maven spring-boot intellij-idea


【解决方案1】:

只需安装 lombok 插件并重新启动 IDEA ,希望可以正常工作。您可以按照以下步骤操作:

  1. 转到文件>设置>插件
  2. 点击浏览存储库
  3. 搜索龙目岛
  4. 点击安装插件
  5. 重启 IntelliJ IDEA
  6. 干净构建项目
  7. 如果仍然无法正常工作,请转到 文件 |使缓存无效/重新启动

【讨论】:

    【解决方案2】:

    确保启用注释处理,并安装 intelij lombok 插件

    看到这个enter link description here

    【讨论】:

      猜你喜欢
      • 2018-12-10
      • 2021-06-24
      • 1970-01-01
      • 2014-06-22
      • 2018-09-07
      • 2014-07-23
      • 2019-12-07
      • 1970-01-01
      相关资源
      最近更新 更多