swagger注解属性设置导致的报错:For input string: ““

使用swagger的时候,用 @ApiModelProperty 修饰的类的属性如果没设置的话默认赋值为"",当Integer类型的属性没设置example的话就会报错

错误设置:

java 复制代码
@ApiModelProperty(value = "设备id")
private Integer typeId;
java 复制代码
Illegal DefaultValue null for parameter type integer
java.lang.NumberFormatException: For input string: ""
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_391]
	at java.lang.Long.parseLong(Long.java:601) ~[na:1.8.0_391]
	at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_391]
	at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) ~[swagger-models-1.5.20.jar:1.5.20]
	at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_391]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_391]
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688) [jackson-databind-2.9.8.jar:2.9.8]

正确设置:

java 复制代码
@ApiModelProperty(value = "设备id",example = "1")
private Integer typeId;
相关推荐
科技道人2 分钟前
记录 默认置灰/禁用 app ‘Search Engine Selector‘ 的disable按钮
开发语言·前端·javascript
伊玛目的门徒10 分钟前
试用leetcode之典中典 二数之和问题
java·算法·leetcode
逝水无殇2 小时前
C# 异常处理详解
开发语言·后端·c#
懒鸟一枚3 小时前
深入理解 Linux 内存、Swap 交换分区与分页机制的关系
java·linux·数据库
玖玥拾4 小时前
C# 语言进阶(十五)C# 游戏服务端 MySQL 数据库
服务器·开发语言·网络·数据库·mysql·c#
铅笔侠_小龙虾4 小时前
Rust 学习目录
开发语言·学习·rust
我命由我123454 小时前
执行 Gradle 指令报错,无法将“grep”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
考虑考虑5 小时前
Sentinel安装
java·后端·微服务
云泽8085 小时前
从零吃透 C++ 异常:抛出捕获、栈展开、异常重抛与编码规范详解
开发语言·c++·代码规范
灯澜忆梦5 小时前
GO---可见性规则
开发语言·golang