繁体   English   中英

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:无法构造实例

[英]com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of

我正在创建 spring web 应用程序并尝试使用货币数据(javamoney.moneta)添加新实体。 这是代码:

@Column(name = FLD_MONEY, unique = false, nullable = true)
private FastMoney money;

private String currencyUnit;
 
public AbstractClient() {
}

public AbstractClient(String clientId, String name, String email, String password, String roles, BigDecimal money, String currencyUnit) {
    this.currencyUnit=currencyUnit;
    this.clientId = clientId;
    this.name = name;
    this.money=FastMoney.of(money, Monetary.getCurrency(this.currencyUnit));
    this.email = email;
    this.password = hashPassword(password);
    this.active=true;
    this.roles=roles;
}

添加到表中的货币列和数据将用 FastMoney 填充。 FastMoney 正在从 BigDecimal money 和 String currencyUnit 的构造函数内部创建。

当我尝试使用带有 json 主体的 API 端点保存时,我遇到了这个问题:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
无法构造 org.javamoney.moneta.FastMoney 的实例(没有创建者,如默认构造函数,存在):没有 int/Int-argument 构造函数/工厂方法从数字值反序列化 (32)


Here is JSON:

```json
{
   
    "money": 32,
    "currencyUnit": "EUR",
    "clientId": "Berik7182",
    "name": "Berik",
    "email": "berik@gmail.com",
    "password": "Berik123",
    "active": true,
    "roles": "ROLE_USER",
    "location": "Pecs",
    "pwcons": 30.0
    
}

我应该怎么办?

我犯了错误,当我在 JSON 中写钱时,我想放 integer 但系统认为我在写 FastMoney。 所以我只是创建了另一个 int 并更改了名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM