Swagger升级到3.0出现的问题

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

posted @ 2021-12-05 15:06  一刹流云散  阅读(474)  评论(0编辑  收藏  举报