解決io.swagger.models.parameters.AbstractSerializableParameter:421|Illegal DefaultValue null for pa...

原因大概是這樣的:
由于實體類使用@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>

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容