java.lang.StackOverflowError: null
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:708)
这是我在使用时得到的异常 查找方法. 我正在使用 Spring Boot JPA 存储库。
@Entity
@Table(名称 ="商店"( 公共类 StoreEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long store_id;
private String storeDescription;
private String storeName;
private String lattitude;
private String longitude;
private boolean isActive;
private boolean is247;
private Date createdDate;
private Date lastModifiedBy;
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL)
@JsonIgnoreProperties(value ="store", allowSetters=true)
private Set<GroceryItemEntity> groceryItem;
@Table(名称="杂货店"( public class GroceryItemEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long grocery_id;
private String name;
private String description;
private double price;
private boolean isActive;
private Date createdDate;
private Date lastModifiedBy;
@ManyToOne(cascade = CascadeType.ALL )
@JoinColumn(name = "store_id")
@JsonIgnoreProperties(value ="groceryItem", allowSetters=true)
private StoreEntity store;
部分例外情况
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:708)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
@JsonIgnoreProperties(value ="groceryItem", allowSetters=true)
用于所有映射,修复无限递归问题。
实际上,我更改了应用程序的结构。在端点中使用 vo 而不是实体类