首页 > 其他分享 >Bug记录:Content-Type 'application/json;charset=UTF-8' is not supported异常解决

Bug记录:Content-Type 'application/json;charset=UTF-8' is not supported异常解决

时间:2024-06-07 21:22:49浏览次数:17  
标签:charset java Type supported module util api UTF com

Content-Type 'application/json;charset=UTF-8' is not supported异常解决

前提:确定不是因为Content-Type导致的异常,controller层有注解@RequestBody。

报错详情:

image-20240522102453237

确定不是因为缺少Jackson依赖或者版本过低:

image-20240522102815355

注意到报错信息上边有一条警告日志:

.c.j.MappingJackson2HttpMessageConverter : Failed to evaluate Jackson deserialization for type [[simple type, class com.xxx.ddd.api.OpenApiRequest<com.xxx.admin.api.insuranceProductConfig.models.request.UpdateComponentByComponentCodeReq>]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Failed to call `setAccess()` on Constructor 'java.util.Objects' (of class `java.util.Objects`) due to `java.lang.reflect.InaccessibleObjectException`, problem: Unable to make private java.util.Objects() accessible: module java.base does not "opens java.util" to unnamed module @77eca502

刚开始只是以为因为执行反序列化出错,看到module java.base does not "opens java.util" to unnamed module联想到是jdk17的问题,在jvm启动参数加上--add-opens java.base/java.util=ALL-UNNAMED后,发现真正报错原因如下:

image-20240522142741526
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.Objects` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('map')
 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 56, column: 16] (through reference chain: com.xxx.ddd.api.OpenApiRequest["requestParams"]->com.xxx.admin.api.insuranceProductConfig.models.request.UpdateComponentByComponentCodeReq["components"]->java.util.ArrayList[0]->com.xxx.admin.api.insuranceProductConfig.models.valueObject.config.ComponentItem["context"]->java.util.LinkedHashMap["map"])

经排查定位到入参对象引用的一个java对象,在网上找解决方法是增加一个readValue的构造函数,如:https://blog.csdn.net/qq_30162239/article/details/86647164,目前还没有搞懂这种解决方法,后续再遇到这类情况再深入了解吧。或者要么对不想序列化的field加@JsonIgnore注解。


本博客内容仅供个人学习使用,禁止用于商业用途。转载需注明出处并链接至原文。

标签:charset,java,Type,supported,module,util,api,UTF,com
From: https://www.cnblogs.com/zhaobo1997/p/18237888

相关文章

  • FFmpeg结构体:AVInputFormat
    1.描述AVInputFormat是类似COM接口的数据结构,表示输入文件容器格式,着重于功能函数,一种文件容器格式对应一个AVInputFormat结构,在程序运行时有多个实例,位于avoformat.h文件中。2.结构体定义1typedefstructAVInputFormat{2/**3*Acommaseparated......
  • 报错 urllib3 (1.26.7) or chardet (5.2.0)/charset_normalizer (2.0.8) doesn‘t mat
    报错RequestsDependencyWarning:urllib3(1.26.7)orchardet(5.2.0)/charset_normalizer(2.0.8)doesn'tmatchasupportedversion!warnings.warn("urllib3({})orchardet({})/charset_normalizer({})doesn'tmatchasupported"这个警告信息Req......
  • 将某xlsx文件转为UTF-8编码格式
    问题:        在使用jupyter对数据进行处理时,导入的文件可能不是UTF-8编码格式,这时就要将文件转为UTF-8。处理:    (1)将文件使用excel打开。    (2)点击左上角文件    (3)选择其他格式,将文件类型选为csvUTF-8格式。    (4)再次将文......
  • c++在Linux下把gbk编码转为utf8编码类型
    #include<iostream>#include<string.h>#include<iconv.h>#include<memory>std::stringgbk_to_utf8(conststd::string&gbk_str){size_tin_len=gbk_str.size();size_tout_len=in_len*4;//设置足够大,确保可以存放转换后的UTF-8字符串std::uni......
  • mapreduce的多种格式文件输出-自定义OutputFormat
    /***@description:mapreduce多种格式的文件输出方式*/publicclassMultipleTypeOutputFormat<K,V>extendsFileOutputFormat<K,V>{privatestaticfinalStringORCEXTENSION=".orc";privatestaticfinalStringCSVEXTENSION=".c......
  • 【异常错误】RTX 4090 nvcc fatal : Unsupported gpu architecture ‘compute_89‘
    https://mapengsen.blog.csdn.net/article/details/137865369?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-3-137865369-blog-123348901.235%5Ev43%5Epc_blog_bottom_relevance_base8&depth_1......
  • 【Java】 如何解决Java中的UnsupportedClassVersionError错误
    >>【痕迹】QQ+微信朋友圈和聊天记录分析工具>>(1)纯Python语言实现,使用Flask后端,本地分析,不上传个人数据。>>(2)内含QQ、微信聊天记录保存到本地的方法,真正实现自己数据自己管理。>>(3)数据可视化分析QQ、微信聊天记录,提取某一天的聊天记录与大模型对话。>>**下载......
  • NOI模拟 UTF-8
    涉及知识点:数位DP前言其实这题也没啥好写的,就是好久没做大模拟调代码把人调废了,警醒一下自己……题意大模拟,不给简化题意了\(n\leq10^5\)。思路大递推DP里面套小数位DP,挺恶心的。设\(f_i\)为以第\(i\)字节结尾的方案数,每次考虑用\(4\)个字节存并且是以\(i\)......
  • Content-Type 'application/json;charset=UTF-8' is not supported异常解决
    Content-Type'application/json;charset=UTF-8'isnotsupported异常解决前提:确定不是因为Content-Type导致的异常,controller层有注解@RequestBody。报错详情:确定不是因为缺少Jackson依赖或者版本过低:注意到报错信息上边有一条警告日志:.c.j.MappingJackson2HttpMessageCo......
  • MySQL升级8.0的新故障,utf8mb4_0900_ai_ci是啥?
    https://blog.csdn.net/LINgZone2/article/details/129730790 前段时间,遇到一个mysql的问题,我仔细看看报错信息,应该是MySQL数据库报出来的,大意是说:collation不兼容,一个是utf8mb4_0900_ai_ci,另一个是utf8mb4_general_ci。utf8mb4_general_ci这玩意儿我见过,是针对utf8mb4编码的......