Springboot integrates the springfox error used by swagger

created at 06-02-2022 views: 12

problem

Springboot integrates springfox used by swagger to report an error Investigated as a version bug

Error:

Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

Under normal circumstances, import the relevant dependencies, then configure the configuration class, and the interface can be used directly with annotations

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>

When springboot 2.6.0 is used together with springfox-swagger 3.0.0, an error will be reported and the project will not start normally.

solution

A temporary workaround is to change to a working version:

springboot 2.5.6/2.5.7

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>

springfox-swagger2 2.9.2

springfox-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>
created at:06-02-2022
edited at: 06-02-2022: