org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal charac

这篇具有很好参考价值的文章主要介绍了org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal charac。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

springcloud在远程调用其他微服务时报错

 at [Source: (PushbackInputStream); line: 1, column: 2]
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
 at [Source: (PushbackInputStream); line: 1, column: 2]
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:284)
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:242)
	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:205)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:158)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:131)
	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
 at [Source: (PushbackInputStream); line: 1, column: 2]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1851)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:707)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._throwInvalidSpace(ParserMinimalBase.java:685)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:3007)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:719)
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4662)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4511)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3519)
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:273)
	... 58 common frames omitted

该异常是由于Spring Cloud Feign 请求其他微服务时json数据太大被压缩导致的,在配置文件中将该参数调大些即可

# feign 配置
feign:
  sentinel:
    enabled: true
  okhttp:
    enabled: true
  httpclient:
    enabled: false
  client:
    config:
      default:
        connectTimeout: 30000
        readTimeout: 30000
  compression:
    request:
      enabled: true
      min-request-size: 10000
    response:
      enabled: true

添加配置

      min-request-size: 10000文章来源地址https://www.toymoban.com/news/detail-769558.html

到了这里,关于org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal charac的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for

    SpringBoot请求接口报错 这是我的实体类 可以发现我的实体类并没有set和get方法才会报错 HttpMediaTypeNotAcceptableException 修改之后添加set和get方法,可以成功运行

    2024年02月12日
    浏览(70)
  • spring.HttpMessageNotReadableException: JSON parse error

    实体类如下: spring.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of com.erato.xxx.Student (although at least one Creator exists): cannot deserialize from Object value (no-delegate- or property based Creater); nested exception is com.fastetxml.jackson.databind.exc.MismatchedInputException: … 去网上一搜,全都在说

    2024年02月12日
    浏览(30)
  • HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.List

     今天与到一个报错,分享一下这个报错的解决方案,都是自己学的太浅的原因导致卡了半个小时 如图: 在Post请求的过程中,前端是一个JSON对象以请求体的形式传到了后端,而后端是以一个列表接收,这样导致的问题就是接收的不是一个对象 在Post请求想要接收请求体的数

    2024年01月16日
    浏览(57)
  • 已解决org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factor

    已解决org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factory.异常的正确解决方法,亲测有效!!! org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factor 对于 org.springframework.beans.factory.UnsatisfiedDependencyException 异常,通常是由于依赖注

    2024年02月05日
    浏览(46)
  • org.springframework.context.ApplicationContextException: Failed to start bean ‘org.springframework.a

    使用RabbitMq测试交换机、队列时候报的错 一开始我以为是队列的监听器配置信息和监听器代码写错了,反复查看并没有错误。 然后继续往下看报错,有这俩报错,瞬间顿悟。 ACCESS_REFUSED 这么大个字,看了好几遍居然没想到这方面的错误,大概是配置密码的时候copy错了 hotel

    2024年02月15日
    浏览(51)
  • 报错:org.springframework.jdbc.BadSqlGrammarException:

    //报错 2024-02-24 19:44:10.814 ERROR 6184 --- [nio-9090-exec-5] c.e.exception.GlobalExceptionHandler     : 异常信息: org.springframework.jdbc.BadSqlGrammarException:  根据异常信息,这是一个Spring框架抛出的`BadSqlGrammarException`异常,通常这个异常表示SQL语法错误。 要解决这个问题,你需要做以下几步:

    2024年04月10日
    浏览(45)
  • org.springframework.data.mongodb.UncategorizedMongoDbException

    org.springframework.data.mongodb.UncategorizedMongoDbException: Runner error: Overflow sort stage buffered data usage of 33700095 bytes exceeds internal limit of 33554432 bytes; nested exception is com.mongodb.MongoException: Runner error: Overflow sort stage buffered data usage of 33700095 bytes exceeds internal limit of 33554432 bytes 这个异常通常会在

    2024年02月12日
    浏览(33)
  • 关于org.springframework.beans.factory.NoSuchBeanDefinitionException

    这个报错可能是因为: 1. spring的xml配置文件Bean中的id和getBean的id不一致 spring的配置文件中: 而程序中 applicationContext.getBean(“studenta”, Student.class)中的是studenta而spring配置文件的id是student,不一致。 2. 是否是忘记加注解了 @Resource或@Autowired都可以(@Resource是jdk自带的) 3.如果

    2024年02月13日
    浏览(66)
  • org.springframework.util.StopWatch使用说明

    StopWatch是一个简单实用的秒表工具类,可以用来评估代码块的执行时间和性能。 以下是StopWatch的主要用法: 创建StopWatch对象 启动秒表计时 执行需要计时的代码块 停止秒表计时 获取执行时间 间隔计时 可以通过多次调用start()和stop()进行间隔计时。 例如: 然后可以通过getTaskTim

    2024年02月03日
    浏览(35)
  • java: 无法访问org.springframework.boot.SpringApplication

    报错信息 报错信息里所说的类文件版本指的是java class file version,java类文件版本 该版本号与jdk版本号存在对应关系,61.0对应jdk17,52.0对应jdk8。 完整对应关系参见 https://stackoverflow.com/questions/9170832/list-of-java-class-file-format-major-version-numbers 所以是某个依赖的版本太高,降低版本

    2024年02月11日
    浏览(53)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包