首页 > 其他分享 >SpringBoot2.7集成Swagger3

SpringBoot2.7集成Swagger3

时间:2023-03-30 18:13:17浏览次数:34  
标签:集成 SpringBoot2.7 3.0 Swagger3 apiInfo build io springfox any

1、引入pom坐标

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

2、配置类

@Configuration
public class SwaggerConfig {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().build();
    }
}

3、application.yml配置

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

4、重启项目访问swagger页面

http://127.0.0.1:8090/swagger-ui/index.html

 

标签:集成,SpringBoot2.7,3.0,Swagger3,apiInfo,build,io,springfox,any
From: https://www.cnblogs.com/sun-10387834/p/17273881.html

相关文章