记录一下使用swagger2遇到的坑
方法执行的功能是根据用户id对User对象进行查询,
首先看我原来的代码:
@ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
// 添加接口参数说明注解
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer", paramType = "path")//dataType = "Integer",web页面无法进入请求
@RequestMapping(value = "user/{id}", method = RequestMethod.GET)//put方法报错
public ResponseEntity<JsonResult> getUserById (@PathVariable(value = "id") Integer id)
{...}
对应的web页面执行时是这样的,
打开网页检查,并没有进入请求,
花费很长时间查看,终于发现问题了,
当我把 @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer", paramType = "path");
中的dataType = "Integer"
换成dataType = "Long"
以后,能够正常执行查询了.
然鹅我并没有搞明白这是为什么,欢迎品论区讨论,求解。