Post Spring数据Rest绑定
我正在尝试使用Spring数据Rest,但我挂起的是Spring没有绑定通过Post提供的我的身体对象 我的域类看起来像:Post Spring数据Rest绑定,post,binding,spring-data-rest,Post,Binding,Spring Data Rest,我正在尝试使用Spring数据Rest,但我挂起的是Spring没有绑定通过Post提供的我的身体对象 我的域类看起来像: @Entity @EqualsAndHashCode @ToString public class Rendite{ @Id @GeneratedValue Long id; double jahresNettoMiete; public Rendite(){} } @RepositoryRestResource(collectionResourc
@Entity
@EqualsAndHashCode
@ToString
public class Rendite{
@Id @GeneratedValue Long id;
double jahresNettoMiete;
public Rendite(){}
}
@RepositoryRestResource(collectionResourceRel = "renditen", path = "renditen")
public interface RenditeRepositoryextends CrudRepository<Rendite, Long> {}
@实体
@EqualsAndHashCode
@托斯特林
公共级Rendite{
@Id@GeneratedValue长Id;
双刺蛾;
公共格式副本(){}
}
@存储资源(collectionResourceRel=“renditen”,path=“renditen”)
公共接口RenditeRepositoryExtendedCrudepository{}
拨打via Get可以正常工作:
调用POST以保存实体也会调用应用程序,但它不会将值绑定到属性:
您的实体上似乎缺少getter(和可选的)setter 为相关字段添加公共getter应同时允许序列化和反序列化 请参阅此处的进一步内容: 非直觉地,getter还使私有字段可反序列化 同样,因为一旦它有了一个getter,这个字段就被认为是一个 财产 您可以通过本文中概述的各种方式控制序列化/反序列化 另一种方法(而不是添加getter)是使用:
@jsonautodect(fieldVisibility=Visibility.ANY)
如下面示例4.5所述:
您的实体上没有获得者或设定者?我很愚蠢。。。谢谢你,如果你做了一个正式的回答,那么你就可以投票了。:-)