当前位置: 首页 > news >正文

SpringBoot整合swagger实现接口管理并设置加密访问

  • pom.xml
    pom.xml文件加入swagger
  • <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version></dependency><dependency><groupId>com.github.xiaoymin</groupId><artifactId>swagger-bootstrap-ui</artifactId><version>1.9.3</version></dependency>

    编写配置文件 

    SwaggerConfigurer
  • package com.wly.qc.config;import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import springfox.documentation.builders.ApiInfoBuilder;
    import springfox.documentation.builders.PathSelectors;
    import springfox.documentation.builders.RequestHandlerSelectors;
    import springfox.documentation.service.ApiInfo;
    import springfox.documentation.spi.DocumentationType;
    import springfox.documentation.spring.web.plugins.Docket;
    import springfox.documentation.swagger2.annotations.EnableSwagger2;/*** 注解标示,这是一个配置类,@Configuation注解包含了@Component注解* @aothor wanghc* @date 2022/2/25**/
    @EnableSwaggerBootstrapUI//需要登录才加上改配置
    @Configuration
    @EnableSwagger2
    public class SwaggerConfigurer  {@Beanpublic Docket createRestApi() {return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.wliyun.qc.controller")).paths(PathSelectors.any()).build();}private ApiInfo apiInfo() {return new ApiInfoBuilder().title("后质控系统api文档").description("API").termsOfServiceUrl("").version("1.0").build();}
    }
    

    application.yml文件内需要添加的内容

  • swagger:production: falsebasic:enable: trueusername: rootpassword: test

http://www.lryc.cn/news/58524.html

相关文章:

  • C语言单例模式-实现高性能日志管理器
  • Flutter - flutter项目添加 Web 支持
  • 关键词数据分析-搜索词和关键词分析工具
  • SpringCloud微服务技术栈之网关服务Gateway
  • 什么原因导致了儿童自闭症?跟父母养育有关吗?
  • 抽象轻松web
  • 如何获取系统下目录的文件系统类型
  • 【Linux】GCC编译器的使用
  • 浅谈一下socks5协议原理详解与应用场景分析
  • java面试准备17
  • ffmpeg的滤镜
  • springboot项目感受03
  • notion插件:为你的工作流带来新生
  • 【python】Jupyter的使用(python代码编辑器)
  • 面试官:你做过什么有亮点的项目吗?
  • 【华为OD机试真题】猜字谜(javapython)
  • 制作真人手办有哪些不便?怎么解决?
  • 网络安全行业现在好混吗,工资水平怎么样?
  • 【SpringBoot】面试组合技-天羽屠龙舞,SpringBootApplication注解的作用是什么?SpringBoot怎么实现自动装配的?
  • 2023-4-10-用Pthreads计算积分
  • 什么是js?js的基本使用
  • 自然数的拆分问题 字典序
  • 软件测试——概念篇
  • Qsort函数的应用与讲解
  • 蓝桥杯嵌入式第九届客观题解析
  • 多元函数的基本概念——“高等数学”
  • LabVIEW-数值控件和布尔控件
  • R730重组阵列raid5
  • Verilog学习笔记3——数据位宽、阻塞/非阻塞赋值、二进制码、独热码、格雷码比较、编写原则、三态门、
  • C++ Qt智能指针使用教程