java.lang.NoSuchMethodError: java.time.Instant.<init>()当我在rest-API文档(招摇)中尝试使用以下json作为正文进行发布请求时,出现错误:
{
"accountId": "string",
"name": "string",
"value": "string",
"expires": 0
}
Run Code Online (Sandbox Code Playgroud)
这映射到模型:
AccountClientIdentifierEntity{
accountId string
name string
value string
expires integer($int64)
}
Run Code Online (Sandbox Code Playgroud)
现在在我的Java代码中,这个expires属性实际上是一个Instant,但它在某种程度上被解析为一个Integer,所以我想我的问题就在这里,当我用“0”而不是Instant发布时。有人可以帮我解决这个问题,或者至少正确地捕获错误吗?
完整代码: 实体:
/**
* The Class UserEntity.
*/
@XmlRootElement(name = "accountClientIdentifier")
@XmlType(propOrder = { "accountId", "name", "value", "expires"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AccountClientIdentifierEntity {
public static void registerToContextProvider(){
try {
CustomContextProvider.registerClass(com.inteno.iopsys.plugin.restapi.entity.AccountClientIdentifierEntity.class);
} catch (Exception e){
Log.error("Could not register AccountClientIdentifierEntity: "+e.getMessage());
}
}
/** The username. */
private String accountId;
/** The name. */
private String name; …Run Code Online (Sandbox Code Playgroud)