小编Mez*_*zoo的帖子

Spring JPA双向无法评估toString

我已经@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)

hibernate spring-data-jpa

13
推荐指数
2
解决办法
7925
查看次数

Spring Boot自定义HttpMessageConverter

如何配置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)

spring-boot

2
推荐指数
1
解决办法
844
查看次数

标签 统计

hibernate ×1

spring-boot ×1

spring-data-jpa ×1