我已经@JsonIdentityInfo通过Baeldung的博客1解决了JSON递归循环(谢谢)
但是现在,另一个错误发生了:
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate com.mezoo.tdc.model.Payment.toString()
Run Code Online (Sandbox Code Playgroud)
这是我的注册对象:
@Entity
@Table(name="Registration")
@JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
public class Registration implements Serializable {
/*some private variables..*/
// Bidirectional relationship
@OneToMany(mappedBy="registration", cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, fetch = FetchType.LAZY)
private List<Payment> payment;
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("payment", payment)
.toString();
}
}
Run Code Online (Sandbox Code Playgroud)
现在,付款对象:
@Entity
@Table(name="Payment")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
public class Payment implements Serializable {
@ManyToOne
@JoinColumn(name = "registration")
private Registration …Run Code Online (Sandbox Code Playgroud) 如何配置spring boot以添加自定义自定义HttpMessageConverter?我正在使用
AbstractHttpMessageConverter
但我不添加配置.使用Spring MVC Classic将:
<mvc:message-converters register-defaults="true">
<bean class="com.mypackage.TsvMessageConverter"/>
</mvc:message-converters>
Run Code Online (Sandbox Code Playgroud)
但Spring启动,在Application.java中?
@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class Application {}
Run Code Online (Sandbox Code Playgroud)