gpt4 book ai didi

java - Spring Rest 服务未返回完整对象

转载 作者:行者123 更新时间:2023-12-02 09:26:54 27 4
gpt4 key购买 nike

我有一个 Spring 帐户端点,如下所示,它返回一个包含一些数据的对象“Things”数组。出于某种原因,我在调用时只获取对象的一部分。我正在尝试检索一系列事物,其中包括完整的对象,而不仅仅是我在下面得到的奇怪的小节。

@GetMapping("/accounts")
public List<Things> test3() throws JSONException {
tester.clear();
for (int i = 0; i < 4; i++) {
Double db = (double) i;
Things jo = new Things(String.valueOf(i), "c", "a", java.sql.Date.valueOf("2013-09-04"),db, java.sql.Date.valueOf("2013-09-04"),
"d", "e", "f", "g", ko, ko);

tester.add(jo);
}
return tester;

此端点保存在restController 中并返回:

[
{
"postBalance": 0.0,
"intFromDate": "2013-09-04",
"accType": "d",
"accDestination": "e",
"forexBch": "f",
"forexAcc": "g",
"maxLimit": 1111.0,
"minLimit": 1111.0
},
{
"postBalance": 1.0,
"intFromDate": "2013-09-04",
"accType": "d",
"accDestination": "e",
"forexBch": "f",
"forexAcc": "g",
"maxLimit": 1111.0,
"minLimit": 1111.0
},
{
"postBalance": 2.0,
"intFromDate": "2013-09-04",
"accType": "d",
"accDestination": "e",
"forexBch": "f",
"forexAcc": "g",
"maxLimit": 1111.0,
"minLimit": 1111.0
},
{
"postBalance": 3.0,
"intFromDate": "2013-09-04",
"accType": "d",
"accDestination": "e",
"forexBch": "f",
"forexAcc": "g",
"maxLimit": 1111.0,
"minLimit": 1111.0
}
]

数据类如下。

package db2New.jdbc;

import java.sql.Date;

public class Things {
private String customerKey;
private String ccy;
private String sfx;
private Date dateLastAmended;
private Double postBalance;
private Date intFromDate;
private String accType;
private String accDestination;
private String forexBch;
private String forexAcc;
private Double maxLimit;
private Double minLimit;

public Things(String customerKey, String ccy, String sfx, Date dateLastAmended, Double postBalance,
Date intFromDate, String accType, String accDestination, String forexBch, String forexAcc, Double maxLimit, Double minLimit) {
setCustomerKey(customerKey);
setCcy(ccy);
setSfx(sfx);
setDateLastAmended(dateLastAmended);
setPostBalance(postBalance);
setIntFromDate(intFromDate);
setAccType(accType);
setAccDestination(accDestination);
setForexBch(forexBch);
setForexAcc(forexAcc);
setMaxLimit(maxLimit);
setMinLimit(minLimit);

}

private String getCustomerKey() {
return customerKey;
}

public void setCustomerKey(String customerKey) {
this.customerKey = customerKey;
}

private String getCcy() {
return ccy;
}

public void setCcy(String ccy) {
this.ccy = ccy;
}

private String getSfx() {
return sfx;
}

public void setSfx(String sfx) {
this.sfx = sfx;
}

private Date getDateLastAmended() {
return dateLastAmended;
}

public void setDateLastAmended(Date dateLastAmended) {
this.dateLastAmended = dateLastAmended;
}

public Double getPostBalance() {
return postBalance;
}

public void setPostBalance(Double postBalance) {
this.postBalance = postBalance;
}

public Date getIntFromDate() {
return intFromDate;
}

public void setIntFromDate(Date intFromDate) {
this.intFromDate = intFromDate;
}

public String getAccType() {
return accType;
}

public void setAccType(String accType) {
this.accType = accType;
}

public String getAccDestination() {
return accDestination;
}

public void setAccDestination(String accDestination) {
this.accDestination = accDestination;
}

public String getForexBch() {
return forexBch;
}

public void setForexBch(String forexBch) {
this.forexBch = forexBch;
}

public String getForexAcc() {
return forexAcc;
}

public void setForexAcc(String forexAcc) {
this.forexAcc = forexAcc;
}

public Double getMaxLimit() {
return maxLimit;
}

public void setMaxLimit(Double maxLimit) {
this.maxLimit = maxLimit;
}

public Double getMinLimit() {
return minLimit;
}

public void setMinLimit(Double minLimit) {
this.minLimit = minLimit;
}

}

最佳答案

该字段的 getter 是私有(private)的,因此您需要将访问权限更改为公共(public)

关于java - Spring Rest 服务未返回完整对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58284020/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com