无法写入HTTP消息:未发现任何属性来创建BeanSerializer

时间:2018-03-13 16:20:09

标签: java spring hibernate jpa spring-data-jpa

我在这个问题上收到错误500。我已经在我的java中添加了但仍然无法从java @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}获取任何数据

这是错误

Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->com.capstone.codegum.Codegum.Objects.BusinessRole["usersId"]->com.capstone.codegum.Codegum.Objects.User_$$_jvst2fa_8["handler"])

BusinessRole.java

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;


@Entity
@Table(name="Business_Roles")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}
public class BusinessRole {

    @Id
    @GeneratedValue(strategy =GenerationType.AUTO)
    private Long businessRoleId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="role")
    private Roles roles;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="business_id")
    private Business business;

    public User getUsersId() {
        return usersId;
    }

    public void setUsersId(User usersId) {
        this.usersId = usersId;
    }

    public Long getBusinessRoleId() {
        return businessRoleId;
    }

    public void setBusinessRoleId(Long businessRoleId) {
        this.businessRoleId = businessRoleId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="users_id")
    private User usersId;

    public Roles getRoles() {
        return roles;
    }

    public void setRoles(Roles roles) {
        this.roles = roles;
    }

    public Business getBusiness() {
        return business;
    }

    public void setBusiness(Business business) {
        this.business = business;
    }



}

如果您需要更多信息,请告诉我我会立即编辑该帖子

0 个答案:

没有答案