我有一个使用集成开发环境 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 编译项目时一切都很好
长风秋雁
梦里花落0921
相关分类