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;
相关推荐
春日见3 小时前
win11 分屏设置
java·开发语言·驱动开发·docker·单例模式·计算机外设
2301_780029043 小时前
支付宝sdk导入错误
java·开发语言·maven
码界奇点4 小时前
基于Spring Boot和Vue3的无头内容管理系统设计与实现
java·spring boot·后端·vue·毕业设计·源代码管理
九皇叔叔4 小时前
【03】微服务系列 之Nacos 注册中心(服务注册)
java·微服务·nacos·架构·注册中心·服务注册
木辰風4 小时前
PLSQL自定义自动替换(AutoReplace)
java·数据库·sql
2501_944525544 小时前
Flutter for OpenHarmony 个人理财管理App实战 - 预算详情页面
android·开发语言·前端·javascript·flutter·ecmascript
heartbeat..4 小时前
Redis 中的锁:核心实现、类型与最佳实践
java·数据库·redis·缓存·并发
5 小时前
java关于内部类
java·开发语言
好好沉淀5 小时前
Java 项目中的 .idea 与 target 文件夹
java·开发语言·intellij-idea
gusijin5 小时前
解决idea启动报错java: OutOfMemoryError: insufficient memory
java·ide·intellij-idea