Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用getter方法时,我收到一个错误(HttpMessageNotWritableException:无法写入JSON:bean类的无效属性';')_Java_Spring_Spring Boot - Fatal编程技术网

Java 使用getter方法时,我收到一个错误(HttpMessageNotWritableException:无法写入JSON:bean类的无效属性';')

Java 使用getter方法时,我收到一个错误(HttpMessageNotWritableException:无法写入JSON:bean类的无效属性';'),java,spring,spring-boot,Java,Spring,Spring Boot,我正在使用接口loainterface.java根据请求显示值。我的问题是我遇到了以下错误: Invalid property 'accountNumber' of bean class [com.meteor.coral.portfolio.modules.loanaccount.domain.Loan$HibernateProxy$Vm2InzHB]: Getter for property 'accountNumber' threw exception; nested exception

我正在使用接口
loainterface.java
根据请求显示值。我的问题是我遇到了以下错误:

Invalid property 'accountNumber' of bean class [com.meteor.coral.portfolio.modules.loanaccount.domain.Loan$HibernateProxy$Vm2InzHB]: 
Getter for property 'accountNumber' threw exception; nested exception is java.lang.reflect.InvocationTargetException; 
nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid property 'accountNumber' of bean class 
[com.meteor.coral.portfolio.modules.loanaccount.domain.Loan$HibernateProxy$Vm2InzHB]: Getter for property 'accountNumber' threw exception; 
nested exception is java.lang.reflect.InvocationTargetException 
(through reference chain: org.springframework.data.domain.PageImpl["content"]
->java.util.Collections$UnmodifiableRandomAccessList[0]->com.sun.proxy.$Proxy394["loanId"]->com.sun.proxy.$Proxy395["accountNumber"])]
这是我的
loainterface.java

@JsonPropertyOrder({
    "id",
    "accountNumber"
})
public interface LoanInterface {
    
    public Long getId();

    public String getAccountNumber();
}
@JsonPropertyOrder({
    "id",
    "loanId"
})
public interface BillingProcessInterface {
    
    public Long getId();
    
    public LoanInterface getLoanId();
}
@Entity
@Table(name = "m_billing")
@Data
@EqualsAndHashCode(callSuper = true)
public class BillingProcess extends AbstractPersistableCustom<Long> {
    
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "loan_id", nullable = false)
    private Loan loanId;
}
这是模型,
Loan.java
,我想从中获取以下字段:

@Entity
@Component
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name = "m_loan", uniqueConstraints = { @UniqueConstraint(columnNames = { "account_no" }, name = "loan_account_no_UNIQUE"),
        @UniqueConstraint(columnNames = { "external_id" }, name = "loan_externalid_UNIQUE") })
public class Loan extends AbstractPersistableCustom<Long> {

    @Column(name = "account_no", length = 20, unique = true, nullable = false)
    private String accountNumber;
}
BillingProcess.java
model,其中我调用
Loan.java

@JsonPropertyOrder({
    "id",
    "accountNumber"
})
public interface LoanInterface {
    
    public Long getId();

    public String getAccountNumber();
}
@JsonPropertyOrder({
    "id",
    "loanId"
})
public interface BillingProcessInterface {
    
    public Long getId();
    
    public LoanInterface getLoanId();
}
@Entity
@Table(name = "m_billing")
@Data
@EqualsAndHashCode(callSuper = true)
public class BillingProcess extends AbstractPersistableCustom<Long> {
    
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "loan_id", nullable = false)
    private Loan loanId;
}
@实体
@表(name=“m_账单”)
@资料
@EqualsAndHashCode(callSuper=true)
公共类BillingProcess扩展了AbstractPersistableCustom{
@ManyToOne(可选=false,fetch=FetchType.LAZY)
@JoinColumn(name=“loan\u id”,nullable=false)
私人贷款;
}
来自
loainterface.java
getId
可以工作:

但是当我试图从
Loan.java
中获取其他字段时,比如
accountNumber
,我得到了错误

有人知道如何解决这个问题吗?我是否过度使用或缺少注释的使用? 多谢各位