項目啟動成功后總是打印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