zoukankan      html  css  js  c++  java
  • Spring boot 配置 swagger

    1、maven配置包

    <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.7.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.7.0</version>
    </dependency>

    2、配置类

    @Configuration
    @EnableSwagger2
    public class Swagger2Config {
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.example.demo")) //这里改成你报controller报名即可
                    .paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo apiInfo() {
    
            return new ApiInfoBuilder()
                    .title("RESTful APIs")
                    .description("RESTFul API 文档")
                    .version("1.0")
                    .build();
        }
    }

    3、访问地址: http://localhost:8080/swagger-ui.html

    官方使用说明:http://springfox.github.io/springfox/docs/current/

  • 相关阅读:
    如何在Altium中下载并添加软件没有的苦文件【转】
    20121124
    变量作用域&函数作用域
    http相关知识
    函数声明和函数表达式
    js中constructor和prototype
    委托模式
    js跨域
    原型和原型链
    javascript 数据类型
  • 原文地址:https://www.cnblogs.com/rufus-hua/p/7197379.html
Copyright © 2011-2022 走看看