0

I have a SpringBoot project with Lombok using the integrated development environment IntelliJ IDEA, with this 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:

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

enter image description here

but when I compile the project using maven everything is fine

en Peris
  • 1,537
  • 12
  • 31
  • 63

2 Answers2

2

Just install lombok plugin and restart the IDEA , hope will work. You can follow the steps below:

  1. Go to File > Settings > Plugins
  2. Click on Browse repositories
  3. Search Lombok
  4. Click on Install plugin
  5. Restart IntelliJ IDEA
  6. clean build the project
  7. If still doesn't work, go to File | Invalidate Caches/Restart
user404
  • 1,934
  • 1
  • 16
  • 32
0

Be sure you enable annotation processing, and install intelij lombok plugin

See this one enter link description here

Alex Faster
  • 199
  • 10