springboott+swagger

简介: 接口引入swagger 说明文档

1.引入依赖

<!-- 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>
    <!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>2.1.10</version>
    </dependency>
  1. 配置文件

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Order(40)
@Configuration
@EnableSwagger2
@ComponentScan("com.yhr.jixiao.admin.controller")
//@Profile({"dev","test"})
//@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
public class Swagger2Config {

@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(new ApiInfoBuilder()
                    .title("阅文HR_绩效管理后台_接口文档")
                    .description("绩效管理后台")
                    .contact(new Contact("yhr", null, "xxx@163.com"))
                    .version("版本号:1.0")
                    .build())
            .enable(true)
            .select()

// .apis(RequestHandlerSelectors.basePackage("com.yhr.menu.controller"))
// .paths(PathSelectors.any())

            .build();
}
private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
            .title("阅文HR_绩效管理后台_接口文档")
            .description("绩效管理后台")
            .contact(new Contact("yhr", "url", "xxx@163.com"))
            .version("1.0")
            .build();
}

}

  1. 1)controller 注解
    @Api(value = "菜单数据Controller", tags = { "菜单" }) `
    2)method 注解
    @ApiOperation(value = "初始化所有在职人员的菜单信息", notes = "计算所有人员的菜单显示权限,缓存到Redis,提升效率", httpMethod = "GET")`
    3)参数注解
    @ApiParam(name="appcode",value="应用clientid",required=true) @RequestParam("appcode")String appcode, @ApiParam(name="badge",value="员工工号",required=true)@RequestParam("badge")String badge`
相关文章
|
关系型数据库 数据库 PostgreSQL
flink postgresql cdc实时同步(含pg安装配置等)
flink postgresql cdc实时同步(含pg安装配置等)
1106 0
|
机器学习/深度学习 JSON 监控
使用Redis实现延时任务(一)(下)
最近在生产环境刚好遇到了延时任务的场景,调研了一下目前主流的方案,分析了一下优劣并且敲定了最终的方案。这篇文章记录了调研的过程,以及初步方案的实现。
211 0
使用Redis实现延时任务(一)(下)
|
Dubbo Java 应用服务中间件
dubbo 教程
先给出阿里巴巴dubbo的主页:http://code.alibabatech.com/wiki/display/dubbo/Home-zh 自己的demo下载地址:http://download.csdn.net/detail/u012049463/6763315 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RP
5668 0
|
Windows
Win7以管理员方式运行cmd.exe
  以管理员(Administrator)方式运行C:\Windows\System32\cmd.exe  
708 0
|
5天前
|
存储 人工智能 安全
AI 越智能,数据越危险?
阿里云提供AI全栈安全能力,为客户构建全链路数据保护体系,让企业敢用、能用、放心用
|
8天前
|
域名解析 人工智能
【实操攻略】手把手教学,免费领取.CN域名
即日起至2025年12月31日,购买万小智AI建站或云·企业官网,每单可免费领1个.CN域名首年!跟我了解领取攻略吧~