首页>代码>搭建Spring Boot中使用Swagger2构建RESTful APIs>/sm/src/main/java/com/mch/boot/sm/config/Swagger2.java
package com.mch.boot.sm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Date  2021-01-04
 * @Desc swagger2
 * @author mch
 */

@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mch.boot.sm"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Spring Boot中使用Swagger2构建RESTful APIs")
                .description("更多Spring Boot相关文章请关注:https://blog.csdn.net/mchgogo?spm=1001.2101.3001.5343")
                .termsOfServiceUrl("https://blog.csdn.net/mchgogo?spm=1001.2101.3001.5343")
                .contact("木槿开成万花町c")
                .version("1.0")
                .build();
    }
}
最近下载更多
大神程序员  LV23 7月10日
微信网友_6368711690080256  LV3 2023年2月28日
0592lyj  LV9 2023年2月16日
906933050  LV1 2022年10月9日
zhulei886  LV14 2021年5月19日
xhmpmail  LV17 2021年2月22日
lincolnpan  LV9 2021年2月2日
diadream  LV3 2021年1月18日
最代码官方  LV168 2021年1月10日
最近浏览更多
大神程序员  LV23 7月10日
内心向阳  LV4 2023年11月7日
微信网友_6368711690080256  LV3 2023年2月28日
jk-mack  LV5 2023年2月19日
0592lyj  LV9 2023年2月16日
906933050  LV1 2022年10月9日
wsupsup  LV16 2022年9月28日
哎呀马吖  LV6 2022年8月24日
2468867327  LV10 2022年5月17日
nbtest  LV1 2022年2月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友