首页 > 技术文章 > Swagger升级到3.0出现的问题

Liuyunsan 2021-12-05 15:06 原文

springboot使用swagger3.0时,访问http://localhost:8080/swagger-ui.html页面404,无法访问

需要导入springfox启动类依赖

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
</dependency>

在主启动类中加上 @EnableOpenApi

@EnableOpenApi
@SpringBootApplication
public class Springboot09SwaggerApplication {

    public static void main(String[] args) {
        SpringApplication.run (Springboot09SwaggerApplication.class, args);
    }

}

Swagger 3.0源码项目结构为

最后访问 http://localhost:8080/swagger-ui/index.html

推荐阅读