2021-04-12 Swagger : i.s.m.p.AbstractSerializableParameter : Illegal DefaultValue null

问题:

Spring Boot 项目里面引入了 Swagger启动报这个错

i.s.m.p.AbstractSerializableParameter : Illegal DefaultValue null for parameter type integer

Swagger 版本2.9.2

原因:

是swagger2.9.2引用的swagger-models 和 swagger-annotations 这两个lib的对应版本有问题1.5.20。这个bug并不影响使用,但是影响观感,因为项目一启动就会报这样一个错。

解决:

方式一:application.yml文件中

logging:
    io:
      swagger:
        models:
          parameters:
            AbstractSerializableParameter: error

 

方式二:pom.xml中排除缺陷版本引入正确版本

maven配置

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-models</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
            <version>1.6.0</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.6.0</version>
            <scope>compile</scope>
        </dependency>

Gradle配置

 //springfox-swagger dependencies
implementation('io.springfox:springfox-swagger2:2.9.2') {
    exclude group: 'io.swagger', module: 'swagger-annotations'
    exclude group: 'io.swagger', module: 'swagger-models'
}
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.swagger:swagger-annotations:1.5.21'
implementation 'io.swagger:swagger-models:1.5.21'
implementation 'io.springfox:springfox-bean-validators:2.9.2'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

正在修炼的IT大佬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值