gpt4 book ai didi

java - 无法捕获 JsonMappingException

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:55:03 27 4
gpt4 key购买 nike

我的 IDE 在 mapper.readValue 行给我错误 Unhandled Exception com.fasterxml.jackson.databind.JsonMappingException

ObjectMapper mapper = new ObjectMapper();
try {
if (response.isEmpty()) {
//Http 204 (No Content) returned from MCC
//We should handle this differently
user = new User();
} else {
user = mapper.readValue(response, User.class);
}
} catch (IOException ioe) {
logger.log(Level.SEVERE, ioe.getLocalizedMessage());
}
return user;

我已经 try catch JsonMappingException 但它并没有使错误消失。有什么想法吗?

最佳答案

当我只添加 jackson-mapper-asl jar 时,我遇到了这个问题。当我添加 jackson-core-asl jar 时,它起作用了。

jackson 2 也是如此。如果您只包含 jackson-databind,则会发生此错误。您还需要包含 jackson-core

关于java - 无法捕获 JsonMappingException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14104956/

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