环境

Java 1.8

SpringBoot 2.1.9

Java 接口代码

    @ResponseBody
@RequestMapping(value = "cloud", method = RequestMethod.GET,produces = "applications/json;charset=UTF-8")
public Boolean queryItemInfoAllInCloud(){
ItemInfo itemInfo = itemService.queryItemInfoAllInCloud();
if(itemInfo == null) return false;
return true;
}

请求路径

http://127.0.0.1:8080/controller/cloud/

警告信息

2019-11-14 14:56:57.465  WARN 57604 Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]

这句话翻译过来就是 "找不到可接受的表示" 可以理解为浏览器找不到合适的类型来显示请求接口的返回值?

然后问题是出在

produces = "applications/json;charset=UTF-8"

这段代码的意思是返回 json 类型的响应数据, 但是我们接口的返回值是 Boolean 类型的, 当然无法返回

所以要这段代码改成

produces=MediaType.APPLICATION_JSON_VALUE

问题圆满解决

[排错] SpringBoot 警告 Could not find acceptable representation的更多相关文章

  1. Springboot实体类转JSON报错Could not find acceptable representation & 设置访问项目根路径的默认欢迎页面

    =================实体类转JSON报错的解决办法============= 之前在springmvc的时候也报过这个错,原因以及springmvc中解决办法参考:https://www ...

  2. SpringBoot导出excel数据报错Could not find acceptable representation

    转自:https://blog.csdn.net/mate_ge/article/details/93518286?utm_source=distribute.pc_relevant.none-tas ...

  3. 76. Spring Boot完美解决(406)Could not find acceptable representation原因及解决方法

    [原创文章]        使用Spring Boot的Web项目,处理/login请求的控制器方法(该方法会返回JSON格式的数据).此时如果访问localhost:8080/login.html, ...

  4. spring使用jackson返回object报错:Handler execution resulted in exception: Could not find acceptable representation

    问题:在springmvc中添加Jackson jar包返回Object类型,处理器方法的produces属性不写,默认根据类型,但如果指定了(错误原因)produces = "text/h ...

  5. 使用@ResponseBody 出现错误Could not find acceptable representation

    org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio ...

  6. org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

    异常信息 org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable represen ...

  7. 关于"Could not find acceptable representation"错误

    在项目中调用一个第三方服务,第三方服务是用Spring Boot写成的.结果调用时返回"Could not find acceptable representation"错误. 经 ...

  8. springboot中的406(Not Acceptable)错误

    今天遇到一个很奇怪的问题,我用springboot开发时,用ajax请求服务想返回json数据,页面总是报406错误,这个错误使我郁闷了很久,原来我的后台服务是这么写的 看到没value的后面有个.h ...

  9. Could not find acceptable representation

    引起的原因:    由于设置了@ResponseBody,要把对象转换成json格式,缺少转换依赖的jar包,故此错. 解决办法: <dependency> <groupId> ...

随机推荐

  1. 【转载】C/C++内存管理详解

    转自:http://chenqx.github.io/2014/09/25/Cpp-Memory-Management/ 内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中 ...

  2. 一个超几何函数$_3F_2$的积分

    \[\Large\displaystyle \int_0^\infty{_3F_2}\left(\begin{array}c\dfrac58,\dfrac58,\dfrac98\\\dfrac12,\ ...

  3. json字符串和表相互转化中遇到的一个严重问题

    导致脚本崩溃的一个问题 Import "zm.luae" zm.Init Dim aaa="fdsf23423dsfsdf" dim 结果表=Encode.Js ...

  4. 每天进步一点点------SOPC TIMER (一)

    寄存器图 可以通过操作以下的寄存器来实现对timer(定时器)内核的操作(仅描述32位计数器) 状态寄存器: TO(timeout) :计数器计数到0时,该位置1,之后TO位的值会保持,直到手动清零, ...

  5. unittest 改装框架ascii 排序执行用例,按照自己书写先后顺序执行

    设计思路: 获取成员变量class.__dict__.keys() filter过滤符合要求成员,由于3.x成员dict属性是支持有序的 # coding=utf-8import unittestfr ...

  6. 唠唠C++二级指针、二维数组、指针数组、数组指针等的区分

    今天看c++primer第六章,有这部分的内容,脑子有点糊涂了,看了几篇博客,自己敲了下,记录一下备忘. 二级指针: int **p; 二维数组: int p[10][10]; char q[10][ ...

  7. Springboot 中AOP的使用

    面向切面编程(Aspect Oriented Programming) 是软件编程思想发展到一定阶段的产物,是面向对象编程的有益补充.AOP一般适用于具有横切逻辑的场合,如访问控制.事务管理.性能检测 ...

  8. Dataguard单机—>单机

    本演示案例所用环境: primary Standby OS Hostname CHINA-DB1 CHINA-DB2 OS Version SUSE Linux Enterprise Server 1 ...

  9. 试题编号: 201903-3 试题名称: 损坏的RAID5

    这题的数据未免也太水了,题目的意思好像默认是每块磁盘装载数据的长度是相等的.我写了判断每次取数据是否会超过每块磁盘存的数据的长度,然而并没有什么卵用.交上去20分,写了个数据测了下,如果要求的块太大的 ...

  10. 拿到别人的Django程序如何在本地RUN起来

    在Pycharm IDE下 Edit Configurations 1.检查Python interpreter 2.检查 Working directory 3.Settings 数据库配置