正在测试我的 API 以通过 ID 获取“队列”,并收到以下错误。
出现意外错误(类型=内部服务器错误,状态=500)。 类型定义错误:[简单类型,类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor];嵌套异常是 com.fasterxml.jackson.databind.exc.InvalidDefinitionException:找不到类 org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor 的序列化程序,并且没有发现创建 BeanSerializer 的属性(为避免异常,请禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS)(通过引用链: com.example.ohramsbackend.model.Queue["patentQueue"]->com.example.ohramsbackend.model.Patient$HibernateProxy$dfNQ5Aj5["hibernateLazyInitializer"]) org.springframework.http.converter.HttpMessageConversionException:类型定义错误:[简单类型,类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor];嵌套异常是 com.fasterxml.jackson.databind.exc.InvalidDefinitionException:找不到类 org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor 的序列化程序,并且没有发现创建 BeanSerializer 的属性(为避免异常,请禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS)(通过引用链: com.example.ohramsbackend.model.Queue["patentQueue"]->com.example.ohramsbackend.model.Patient$HibernateProxy$dfNQ5Aj5["hibernateLazyInitializer"])
@Entity
@Table(name="queue")
public class Queue{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long queueId;
@Column(name="requestTime")
private LocalDateTime requestTime;
@Column(name="acceptTime")
private LocalDateTime acceptTime;
@Column(name="completeTime")
private LocalDateTime completeTime;
@Column(name="status")
private String status;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="icNumber")
private Patient patientQueue;
}
我可以知道为什么我无法获取队列吗?提前致谢
最佳答案
我也遇到了同样的问题。
您需要在类名称上方添加 @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
。
@Entity
@Table(name="queue")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Queue {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long queueId;
...
}
查看此post了解更多详情
关于java - 找不到类的序列化程序,没有发现创建 BeanSerializer 的属性(为避免异常,请禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72464121/