解决Swagger2 "Failed to convert value of type 'java.lang.String' to required type 'java.lang报错

解决Swagger2中"message": "Failed to convert value of type ‘java.lang.String’ to required type 'java.lang报错

问题描述

Swagger2中报错如下:
"message": "Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Integer’; nested exception is java.lang.NumberFormatException: For input string: “{id}”"
解决Swagger2 "Failed to convert value of type 'java.lang.String' to required type 'java.lang报错

原因

@ApiImplicitParam注解中没有写paramType = “path” 会提示类型转换String convert to Long错误。
解决Swagger2 "Failed to convert value of type 'java.lang.String' to required type 'java.lang报错

解决办法

在@ApiImplicitParam注解中添加paramType = “path”参数即可解决。
解决Swagger2 "Failed to convert value of type 'java.lang.String' to required type 'java.lang报错