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

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

时间:2024-05-25 16:44:06浏览次数:15  
标签: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/18212589

相关文章

  • 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编码的......
  • MySQL几种编码格式的区别(utf8、utf8mb4、utf8mb4_general_ci、utf8mb4_unicode_ci 、u
    https://cloud.tencent.com/developer/article/1872879存储字符集utf8和utf8mb4utf8是Mysql中的一种字符集,只支持最长三个字节的UTF-8字符,也就是Unicode中的基本多文本平面。要在Mysql中保存4字节长度的UTF-8字符,需要使用utf8mb4字符集,但只有5.5.3版本以后......
  • 数据库全局修改 utf8mb4_general_ci
    --修改数据库字符集和校对规则ALTERDATABASEyour_database_nameCHARACTERSET=utf8mb4COLLATE=utf8mb4_general_ci; --修改表的字符集和校对规则ALTERTABLEyour_table_nameCONVERTTOCHARACTERSETutf8mb4COLLATEutf8mb4_general_ci; --修改列的......
  • index.js from Terser Error: error:0308010C:digital envelope routines::unsupporte
    Vue报错error:0308010C:digitalenveloperoutines::unsupported出现这个错误是因为node.jsV17版本中最近发布的OpenSSL3.0,而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.方法1.打开终端(按健win+R弹出窗口,键盘输入cmd,然后敲回车)并......
  • SSL Medium Strength Cipher Suites Supported (SWEET32)漏洞修复
    近期对公司开发环境的机器进行了安全扫描,在扫描安全报告中出现了SSLMediumStrengthCipherSuitesSupported(SWEET32)漏洞,汇报后领导表示需要进行修复,特记录此漏洞修复的过程。漏洞产生的原因漏洞的原因主要是由于SSL/TLS协议中使用的DES(DataEncryptionStandard)及Trip......
  • mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_pa
    今天将程序部署到服务器,遇到mysql.connector.errors.NotSupportedError:Authenticationplugin'caching_sha2_password'isnotsupported问题产生的原因:从MySQL8.0开始,默认的用户认证插件从mysql_native_password变成了caching_sha2_password查看现有的用户mysql>se......
  • root用户远程登录云服务器失败 No supported authentication methods available (serv
     1、平台:亚马逊AWS云、腾讯云服务器、MobaXterm2、问题:云服务器实例远程登录失败,显示:“Nosupportedauthenticationmethodsavailable(serversent:publickey)”翻译:不支持可用的身份验证方法(服务器发送:publickey)3、解决过程:初步判断:服务器远程登录配置文件问题尝试1:a.......
  • MAC make编译报错 “clang: error: unsupported option '-fopenmp'”
    编译报错➜php_mt_seed-mainmakegcc-Wall-march=native-mtune=generic-O2-fomit-frame-pointer-funroll-loops-fopenmpphp_mt_seed.c-ophp_mt_seedclang:error:unsupportedoption'-fopenmp'clang:error:unsupportedoption'-fopenmp'......
  • MSB410在条件(%(Name)' == InputFile' OR %(Name)' == OutputFile
    问题:在VS2017中配置完了Qtvisualstudiotools插件后,编译时报错< MSB410在条件(%(Name)'==InputFile'OR%(Name)'==OutputFile > 原因及解决方法:插件版本问题,先卸载最新版,下载旧版:https://download.qt.io/archive/vsaddin/  此版本报错 安装后断网,取消自动更......
  • MySQL 创建数据库使用 UTF-8 问题
    问题描述将emoji符号(如......