项目启动成功后总是打印WARN信息
APPLICATION|WARN|||2020-10-15 19:06:56:368|||AbstractSerializableParameter.java:421|getExample||322|||Illegal DefaultValue null for parameter type integer
java.lang.NumberFormatException: For input string: ""
Swagger每一个@ApiModelProperty注解里example属性都会进行非空判断.但是,它在判断的语句里只判断了null的情况,没有判断是空字符串的情况,所以解析数字的时候就会报这个异常
swagger-models 默认是1.5.20,这个版本是没有解决上面这个问题;而在较新的版本1.5.22是解决了这个问题。
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.5.22</version> </dependency>
或者调整日志的级别
# application.yml logging: level: io.swagger.models.parameters.AbstractSerializableParameter: error
# application.properties logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error