原因大概是這樣的:
由于實(shí)體類使用@ApiModelProperty時(shí),example屬性沒有賦值導(dǎo)致的,在AbstractSerializableParameter的getExample方法中會(huì)將數(shù)值屬性的example的轉(zhuǎn)換數(shù)值類返回,example的默認(rèn)值是"",因此當(dāng)example沒有賦值時(shí),會(huì)出現(xiàn)上面的異常
很多解決辦法是添加默認(rèn)值,參考鏈接:https://blog.csdn.net/weixin_44096448/article/details/102542068
如果不想添加默認(rèn)值,可以替換老版本的model替換原有的model模塊
<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.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>