'Many To One' 属性类型不应是容器

'Many To One' attribute type should not be a container

我有这个class:

import org.springframework.security.core.userdetails.UserDetails;

@Entity
@Table(name="t_user")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class User implements Serializable, UserDetails {

@Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }
..
}

但是我有这个编译错误:

'Many To One' attribute type should not be a container 

@ManyToOne 应该注释一个字段而不是一个集合。对于集合字段,正确的注释是 @OneToMany.

所以如果你有

@ManyToOne
private List<Something> list;

应该是

@OneToMany
private List<Something> list;

正如错误所说,manyToOne 不应该是 collection/list 而应该是单个对象

@ManyToOne
Somthing somthing; // but not list