Java 未找到类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor的序列化程序,也未找到用于创建BeanSerializer的属性
我正在使用SpringBoot和SpringDataJPA。但是,当我尝试从存储库检索数据时,会引发以下错误:Java 未找到类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor的序列化程序,也未找到用于创建BeanSerializer的属性,java,spring,hibernate,spring-data-jpa,Java,Spring,Hibernate,Spring Data Jpa,我正在使用SpringBoot和SpringDataJPA。但是,当我尝试从存储库检索数据时,会引发以下错误: Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No seriali
Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.example.model.Pokemon$HibernateProxy$DuUnG9om[\"hibernateLazyInitializer\"])
我看到的大多数“副本”都有关系,但我的口袋妖怪类没有。有什么我遗漏的吗
我的口袋妖怪类是一个简单的POJO类:
package com.example.model;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Pokemon implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2228784815938588107L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private Double attack, defense, speed;
public Pokemon() {
}
public Pokemon(int id, String name, double attack, double defense, double speed) {
super();
this.id = id;
this.name = name;
this.attack = attack;
this.defense = defense;
this.speed = speed;
}
// Getters and setters
}
也许可以尝试向字段添加注释,将列名与字段映射 @列(name=“name”) 私有字符串名称
还是您将注释放在了getter和setter上?我通过使用
@JsonIgnoreProperties
注释解决了这个问题
// package and imports
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties({"hibernateLazyInitializer"})
@Entity
public class Pokemon implements Serializable {
// rest of code
}
尝试添加getter和setters@Aris_Kortex我在最后一行用注释表示了我的getter和setter,我刚刚在每个字段中添加了@Column,但是出现了相同的错误