關於Swagger會報AbstractSerializableParameter類的異常問題


SpringBoot-2.2.1.RELEASE 集成 swagger-ui-2.9.2 時,每次在訪問到頁面時總是報AbstractSerializableParameter類的異常錯誤,大概內容如下:

異常錯誤信息

這里集成的POM信息是:

        <!--引入swagger-ui 2.9.2-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

查找網上資料,說是代碼bug問題,大概是說Swagger每一個@ApiModelProperty注解里example屬性都會進行非空判斷,但是它在判斷的語句里只判斷了null的情況,沒有判斷是空字符串的情況,所以解析數字的時候就會報這個異常.....

需要添加新的依賴,修改POM信息如下:

        <!--引入swagger-ui 2.9.2-->
        <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.6.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

參考資料:https://www.jianshu.com/p/7fdac1e94086


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM