SpringBoot 下使用Swagger3.0

发布时间 2023-09-04 16:17:46作者: 星流残阳

swagger3.0和2.x的版本有一些配置是不一样的,故记录下。

pom.xml依赖

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

Config.java内容

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    public Docket swaggerRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(new ApiInfoBuilder()
                .title("Swagger数据库操作接口").description("api接口文档").version("1.0.0").build())
                .select().paths(PathSelectors.any()).build();
    }
}

页面访问

http://ip:port/swagger-ui/index.html