当我尝试发送带有以下错误的帖子请求时,服务器崩溃:
com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields
我进行了一些调试,发现我收到了此错误,因为我已从User重命名了userDetails实体。但是,我已经对其进行了重构,并且每个变量和引用也都已重命名。还是这个错误。
堆栈跟踪:
package com.travelplanner.rest.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;
@Entity
@Table(name="users_details")
public class UserDetails {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="first_name")
private String firstName;
@Column(name="last_name")
private String lastName;
@Column(name="email")
private String email;
@Transient
@JsonIgnore
private String password;
@OneToMany(mappedBy="userDetails", cascade=CascadeType.ALL)
@JsonIgnore
@JsonManagedReference
private List<TravelPlans> travelPlans;
public UserDetails() {
}
public UserDetails(int id, String firstName, String lastName, String email, String password) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.password = password;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@JsonIgnore
public String getPassword() {
return password;
}
@JsonProperty
public void setPassword(String password) {
this.password = password;
}
public List<TravelPlans> getTravelPlans() {
return travelPlans;
}
public void setTravelPlans(List<TravelPlans> travelPlans) {
this.travelPlans = travelPlans;
}
@Override
public String toString() {
return "User [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + "]";
}
public void add(TravelPlans travelPlan) {
if(travelPlans == null) {
travelPlans = new ArrayList<>();
}
travelPlans.add(travelPlan);
travelPlan.setUser(this);
}
}
用户实体如下:
package com.travelplanner.rest.entity;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@Table(name="travel_plans")
public class TravelPlans {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="place")
private String place;
@Column(name="hotel")
private String hotel;
@Column(name="transport")
private String transport;
@JsonBackReference
@ManyToOne(cascade= {CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
@JoinColumn(name="user_id")
private UserDetails userDetails;
public TravelPlans() {}
public TravelPlans(String place, String hotel, String transport) {
this.place = place;
this.hotel = hotel;
this.transport = transport;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public String getHotel() {
return hotel;
}
public void setHotel(String hotel) {
this.hotel = hotel;
}
public String getTransport() {
return transport;
}
public void setTransport(String transport) {
this.transport = transport;
}
public UserDetails getUser() {
return userDetails;
}
public void setUser(UserDetails userDetails) {
this.userDetails = userDetails;
}
@Override
public String toString() {
return "TravelPlans [id=" + id + ", place=" + place + ", hotel=" + hotel + ", transport=" + transport + "]";
}
}
另一个相关实体:
// when a cell in column A (F:F) is changed, clear the corresponding cell in column C0-DD
function onEdit(e) {
if(e.range.columnStart === 12 && e.range.getValue() != 'V01') {
e.range.offset(0, 81, 1, 5).clearContent();
}
}
请帮助。 预先感谢。