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;
相关推荐
踩着两条虫1 小时前
「AI + 低代码」的可视化设计器
开发语言·前端·低代码·设计模式·架构
JoneBB1 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
budingxiaomoli1 小时前
Spring IoC &DI
java·spring·ioc·di
Spider Cat 蜘蛛猫1 小时前
Springboot SSO系统设计文档
java·spring boot·后端
未若君雅裁1 小时前
MySQL高可用与扩展-主从复制读写分离分库分表
java·数据库·mysql
即使再小的船也能远航2 小时前
【Python】安装
开发语言·python
学习中.........2 小时前
从扰动函数的变化,感受红黑树带来的性能提升
java
Irissgwe2 小时前
类与对象(三)
开发语言·c++·类和对象·友元
计算机安禾2 小时前
【c++面向对象编程】第24篇:类型转换运算符:自定义隐式转换与explicit
java·c++·算法
雪度娃娃2 小时前
转向现代C++——优先选用nullptr而不是0和NULL
开发语言·c++