zoukankan      html  css  js  c++  java
  • springboot配置swagger

    1,添加配置类

    @Configuration
    @EnableSwagger2
    @Profile({"default", "dev-online", "test"})
    public class SwaggerConfiguration {
    
        @Bean
        public Docket appDoc() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(appApiInfo())
                    .directModelSubstitute(Date.class, Double.class)
                    .directModelSubstitute(LocalDate.class, Double.class)
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.example.multidatasource.web"))//换成对应应用入口层级
                    .paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo appApiInfo() {
            return new ApiInfoBuilder()
                    .title("plan-warehousing 接口文档")
                    .version("1.0.0")
                    .build();
        }
    
    }
    

    2,添加pom文件

    <!--swagger支持 -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.7.0</version>
            </dependency>
            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>swagger-bootstrap-ui</artifactId>
                <version>1.9.0</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.7.0</version>
            </dependency>
    

    3,浏览器访问http://localhost:80/doc.html  服务对应端口号

    学习是个漫长的过程,勿忘初心!
  • 相关阅读:
    [hihocoder1509][异或排序]
    [hdu6148][Valley Numer]
    [hdu2089][不要62]
    [luoguU42591][小T的绝对值]
    [luogu2073][送花]
    [bzoj4709][柠檬]
    [luogu2114][起床困难综合症]
    [codevs3342][绿色通道]
    [luoguU42591][小T的面试题]
    [noip][2014]
  • 原文地址:https://www.cnblogs.com/javalhy/p/10582961.html
Copyright © 2011-2022 走看看