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