zoukankan      html  css  js  c++  java
  • spring boot 集成swagger2

     1  在pom.xml中加入Swagger2的依赖

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.8.0</version>
    </dependency>

    2  

    @Configuration
    @EnableSwagger2
    public class SwaggerConfig {
    
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("tech.duor.sunflower"))//扫描包
                    .paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder()
                    .title("标题")
                    .description("描述")
                    .termsOfServiceUrl("http://duor.tech/")
                    .contact("创建人")
                    .version("0.1")
                    .build();
        }
    
    }

    3 . controller

    @Api(description = "xxController", value = "描述")
    @CrossOrigin
    @RestController
    @RequestMapping("/api/system")
    //@Scope("prototype")
    public class PalletController {
    
    
    
    
        @ApiOperation(value = "查询全部的货盘分页展示", notes = "")
        @ApiImplicitParam(name = "Authorization", paramType = "header")
        @RequestMapping(value = "/pallet", method = RequestMethod.GET)
        public RestResult QueryPallets(){}
        
    }

    https://www.jianshu.com/p/8033ef83a8ed

    https://www.imooc.com/article/20521


    在浏览器中输入你配置的网址就可以访问
    http://localhost:8011/index.html

    https://www.jianshu.com/p/528b2db2ab7f

    下载  dist   放到

     修改  index.html

  • 相关阅读:
    [NOIP2011]选择客栈
    [学习笔记]字符串的一些基本操作
    [学习笔记]树链剖分
    [宁波集训]0827Day1
    [POI2015]LOG(树状数组)
    [学习笔记]树形dp
    货车运输(最大生成树+倍增LCA)
    POJ 3617 Best Cow Line 贪心算法
    C++ STL next_permutation() prev_permutation(a,a+n)用法。
    POJ 2386 Lake Counting dfs
  • 原文地址:https://www.cnblogs.com/angdh/p/9910721.html
Copyright © 2011-2022 走看看