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配置

扫描二维码关注公众号,回复: 17275880 查看本文章

 //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'

猜你喜欢

转载自blog.csdn.net/qq_34045989/article/details/115640378