一、问题
swagger2报错illegal defaultvalue null for paramter type integer
二、解决办法
正常swagger2引入
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version>
</dependency>
修改依赖,覆盖默认的版本
<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>
<!-- https://mvnrepository.com/artifact/io.swagger/swagger-models -->
<dependency><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId><version>1.5.21</version>
</dependency>
三、异常分析
异常信息可以看到关于swagger的堆栈信息
at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412)
点进去看之后,代码如下,默认引入1.5.20的包:

注解的 example 默认值都是空字符串 "" ,包括ApiParam、ApiModelProperty、ApiImplicitParam等,经过上面的参数解析,null判断继续运行,执行xx.valueOf(),会打印警告

1.5.21版本的如下,做了空值判断:

github 同样的问题:
https://github.com/springfox/springfox/issues/2528
https://github.com/swagger-api/swagger-core/issues/2783