SpringBoot 2.3 升级到 SpringBoot 2.7 爬坑-- Swagger 3

SpringBoot 2.3 升级到 SpringBoot 2.7 爬坑-- Swagger 报错 需要升级 到 3
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

image

<!-- swagger 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>
<!-- swagger 2 -->
<!-- 引入swagger3包 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>

SwaggerConfig

@Configuration
@EnableSwagger2
@Profile({"dev","test"})  //只有开发、测试环境,支持 swagger
public class SwaggerConfig {}
@Configuration
@EnableOpenApi
public class SwaggerConfig {}
posted @ 2024-10-19 21:37  VipSoft  阅读(46)  评论(0编辑  收藏  举报