当前位置:   article > 正文

feign.codec.DecodeException: Could not extract response: no suitable HttpMessageConverter found

feign.codec.DecodeException: Could not extract response: no suitable HttpMessageConverter found

出错的代码:

  UserBaseDto lmsInfo = userBaseClient.getUserById(pointMqVo.getUserId(), pointMqVo.getPlatformId());

调用的代码:

  1. @ApiOperation(httpMethod = "GET", value = "根据用户Id查询用户信息")
  2. @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String",required = true, paramType = "query"),
  3. @ApiImplicitParam(name = "platformId", value = "平台id", dataType = "String", paramType = "query"),
  4. })
  5. @RequestMapping("/getUserById")
  6. public UserBaseDto getUserById(@RequestParam String userId,@RequestParam(required = false) String platformId) {
  7. UserBaseInfo data = userBaseService.findById(userId, platformId);
  8. return UserBaseInfo.infoToDto(data);
  9. }

报错的信息:

  1. feign.codec.DecodeException: Could not extract response:
  2. no suitable HttpMessageConverter found for response type [class
  3. com.chinahrt.gp6.system.sharevo.UserBaseDto]
  4. and content type [text/html;charset=utf-8]

问题分析:

断点调试时,不走被调用方法上打的断点,我一直怀疑是远程调用不通导致的。

看报错信息,又百度以为是feign调用不支持UserBaseDto这种返回类型,就用了一个返回String类型的方法进行调用测试,当时报SQL错误。突然意识到其实他走被调用方法的查询,并且查询的sql有错,无法返回这个错误信息导致的报上面错误。并不是无法返回UserBaseDto。 

而SQL报错这么简单的问题,我为什么没有发现是因为写测试用例,一般是看这里,这里提示feign.codec.DecodeException: ...,而前面那个Run那里提示SQL运行错误。

sql报错信息如下:

  1. {"code":"UNKNOWN_EXCEPTION","message":"\r\n### Error querying database.
  2. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column
  3. 'platform_id' in 'where clause'\r\n### The error may exist in file
  4. [E:\\liziyi\\xxx\\xxx-system\\target\\classes\\mapper\\UserBaseDao.xml]\r\n###
  5. The error may involve defaultParameterMap\r\n### The error occurred while setting
  6. parameters\r\n### SQL: select
  7. id,name,password,parent_id,idcard,picture,real_name,sex,birthday,mobile,email,
  8. create_time,seal_flag,if_open,weixin_opernid,if_vip,nick_name,thirdparty_id,
  9. thirdparty,user_level,nation,last_login_time,last_login_source,if_test,if_provider,
  10. account_money,last_modify_time,last_pwd_modify_time,if_student,if_manager,
  11. department,position,polevel_id,base_id,political_id,degree_id,prof_id,office_phone,
  12. if_enable_update,if_check,jobtitle_id,obtitle_date,units_natureid,units_fieldid,
  13. office_address,administration_position,domiciliary_register,college,specialty,
  14. degree_no,birth_place,applicants_rating,address,political_title,if_transform,
  15. transform_time,units_industry,bind_id,bind_name,bind_role,bind_plan,info_from,
  16. interest,personal_summary,professional_technical,professional_title,level_name,
  17. work_area,function_level,identity_id,administrative_range,qq,office_nature,my_point,
  18. my_get_point,my_exchange_point,certificate_title_series,certificate_right_name,
  19. certificate_profession_name,bind_user_id,manage_unit,general1,general2,general3,
  20. general4,general5,train_no,train_address,home_address,domiciliary_type,train_type,
  21. train_work_area,train_level,ssn,professional_value from user_base where id=?
  22. AND platform_id = ?\r\n### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column
  23. 'platform_id' in 'where clause'\n; bad SQL grammar []; nested exception is
  24. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column
  25. 'platform_id' in 'where clause'|请求地
  26. 址:http://xxx/xxx/system/serviceApi/user/getUserById,参
  27. 数:userId=111111&platformId=1,traceId="}

解决办法:

现在定位出来,是因为sql的问题,不是服务间调用不同,也不是无法传UserBaseDto这个参,而是SQL报错。把SQL报错的地方修改完成即可。上面SQL报错信息意思是platform_id元素有问题,因为我的表中没有这个元素,我传了这个参数,所以报错。

希望大家准确的定位自己的问题。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/813923
推荐阅读
相关标签
  

闽ICP备14008679号