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

  • 相关阅读:
    Mybatis完成CRUD(四)
    Log4j日志配置
    Mybatis学习笔记(二)配置文件
    Mybatis学习笔记(一)入门例子
    jquery自动将form表单封装成json
    SpringMVC学习笔记(六)
    springMVC学习笔记(五)
    Oracle 数据库语句大全
    J a v a 的“多重继承”
    接口--interface
  • 原文地址:https://www.cnblogs.com/angdh/p/9910721.html
Copyright © 2011-2022 走看看