zoukankan      html  css  js  c++  java
  • 在springboot中使用swagger2

    1、在springboot中使用swagger的话,首先在pom文件中引入依赖
    <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>
    2、创建配置类
    
    
    @Configuration
    @EnableSwagger2
    public class Swagger2Config{
      
          @Bean
            public Docket swaggerSpringMvcPlugin(){
            return new Docket(DocunmentationType.Swagger_2).select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
      }
    
    }
    
    

    3、在controller类上加Api注解

     
    
    
    
    
    
    ZGC说:有什么能比不给牛吃草,还挤牛奶更快乐的事情呢?
  • 相关阅读:
    Hibernate
    Mysql
    JavaWeb
    Springboot
    spring MVC
    spring
    mybatis学习
    ftp客户端封装
    win10子系统 wsl开机启动ssh服务
    eclipse 终于官方支持代码模糊提示了
  • 原文地址:https://www.cnblogs.com/lovestart/p/11210368.html
Copyright © 2011-2022 走看看