swagger-ui使用时打开swagger-ui.html页面后台报错:java.lang.NumberFormatException: For input string: ""

今天使用swagger-ui.html访问时后台报错:java.lang.NumberFormatException: For input string: "".

具体原因是由于我pom引入的io.springfox:springfox-swagger-ui:2.92版本的jar包内置为io.swagger:swagger-models包为1.5.20版本.

       1.5.20版本中判断example只判断是否为null,没有判断example为空字符串""的情况所以报错.1.5.21版本新增了判断example是否为null和"".所以排除1.5.20包重新导入1.5.21包即可解决.解决方案如下:

<!-- swagger2-UI-->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
    <exclusions>
        <exclusion>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- io.springfox:springfox-swagger2:2.9.2中依赖了swagger-models的1.5.20版本,通过排除springfox-swagger2中的swagger-models依赖,
导入io.swagger:swagger-models的1.5.21版本.解决io.swagger.models.parameters.AbstractSerializableParameter实例化参数时example为
空字符串""而报错的问题.因为1.5.20的example只判断是否为null,1.5.21判断了是否为null和""-->
<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-models</artifactId>
    <version>1.5.21</version>
</dependency>

参考:

https://blog.csdn.net/qq122516902/article/details/89673363

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值