一、在启动类中添加如下代码:(目的是为了打印输出swagger的地址等)
注解:@Slf4j
实现接口:CommandLineRunner
依赖注入:

@Autowiredprivate Environment environment;
@Overridepublic void run(String... strings) throws Exception {try {String port = Optional.ofNullable(environment.getProperty("server.port")).orElse("8080");log.info("\n------------------------环境信息---------------------------\n\t" +"Application '{}' is running! Access URLs:\n\t" +"Local  : \thttp://{}:{}\n\t" +"Swagger: \thttp://{}:{}/doc.html\n\t" +"Profile(s): \t{}\n----------------------------------------------------------",environment.getProperty("spring.application.name"),InetAddress.getLocalHost().getHostAddress(),port,InetAddress.getLocalHost().getHostAddress(),port,Arrays.toString(environment.getActiveProfiles()));} catch (UnknownHostException e) {e.printStackTrace();}}

启动类全部代码如下:

/**      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.**  Redistribution and use in source and binary forms, with or without*  modification, are permitted provided that the following conditions are met:**  Redistributions of source code must retain the above copyright notice,*  this list of conditions and the following disclaimer.*  Redistributions in binary form must reproduce the above copyright*  notice, this list of conditions and the following disclaimer in the*  documentation and/or other materials provided with the distribution.*  Neither the name of the dreamlu.net developer nor the names of its*  contributors may be used to endorse or promote products derived from*  this software without specific prior written permission.*  Author: Chill 庄骞 (smallchill@163.com)*/
package org.springblade;import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.launch.BladeApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Optional;/*** 启动器** @author Chill*/
@Slf4j
@EnableScheduling
@SpringBootApplication
public class Application  implements CommandLineRunner {@Autowiredprivate Environment environment;@Beanpublic RestTemplate restTemplate(RestTemplateBuilder builder){return builder.build();}public static void main(String[] args) {BladeApplication.run(CommonConstant.APPLICATION_NAME, Application.class, args);}@Overridepublic void run(String... strings) throws Exception {try {String port = Optional.ofNullable(environment.getProperty("server.port")).orElse("8080");log.info("\n------------------------环境信息---------------------------\n\t" +"Application '{}' is running! Access URLs:\n\t" +"Local  : \thttp://{}:{}\n\t" +"Swagger: \thttp://{}:{}/doc.html\n\t" +"Profile(s): \t{}\n----------------------------------------------------------",environment.getProperty("spring.application.name"),InetAddress.getLocalHost().getHostAddress(),port,InetAddress.getLocalHost().getHostAddress(),port,Arrays.toString(environment.getActiveProfiles()));} catch (UnknownHostException e) {e.printStackTrace();}}}

二、找到需要生成Swagger接口文档的控制器类(eg:ActiveCodeController):
1.在控制器类的上面添加注解:
@Api(value = "卡信息", tags = "卡信息接口")

value里面写的是:这个控制器的描述,或者功能

如图所示:

2.在需要生成文档的方法上写注解:
@ApiOperation(value = "详情", notes = "传入cardInfo")
value:接口的功能或者描述
notes:传入参数的描述
全部代码:

 /*** 详情*/@GetMapping("/detail")@ApiOperationSupport(order = 1)@ApiOperation(value = "详情", notes = "传入cardInfo")public R<CardInfo> detail(CardInfo cardInfo) {CardInfo detail = cardInfoService.getOne(Condition.getQueryWrapper(cardInfo));return R.data(detail);}

或者:

 /*** 分页 卡信息*/@GetMapping("/list")@ApiOperationSupport(order = 2)@ApiOperation(value = "分页", notes = "传入cardInfo")public R<IPage<CardInfo>> list(CardInfo cardInfo, Query query) {IPage<CardInfo> pages = cardInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(cardInfo));return R.data(pages);}

其他的可以自己补充。
三、配置Swagger的配置类,类路径:BladeX-Boot/src/main/java/org/springblade/common/config/SwaggerConfiguration.java

加入如下代码:

 @Beanpublic Docket developerDocket() {return docket("开发者中心接口", Collections.singletonList(AppConstant.BASE_PACKAGES + ".modules.developer"));}

【开发者接口】:就是Swagger的接口功能的名称
【.modules.developer】:让Swagger扫描哪个包,指向包就可以。

然后启动服务,启动完成之后,查看控制台打印的Swagger地址。

点击地址就可以查看

Bladex生成Swagger的方法相关推荐

  1. swagger 扫描java文档_推荐一款在运行时通过javadoc生成Swagger API文档的库

    介绍 一般,我们使用Springfox生成swagger api文档,但Springfox不支持从javadoc中生成,只能通过注解的方式标注文档. 这样,当共享一些POJO类时,为了同时生成java ...

  2. springboot 接口文档 请求 enum_Spring Boot集成SpringFox 3:生成Swagger接口文档

    SpringFox介绍 SpringFox是一个开源的API Doc的框架, 它的前身是swagger-springmvc,可以将我们的Controller中的方法以文档的形式展现.官方定义为:Aut ...

  3. swagger 扫描java文档_使用Javadocs生成Swagger文档

    我想为现有的一组RESTful API构建Swagger文档.我有以下要求: 读取现有的Javadoc,以便可以在Swagger文档中使用它们. 到目前为止使用上面的插件我能够实现第1点.所以对于现有 ...

  4. 自动生成python接口文档_Django自动生成Swagger接口文档

    Django自动生成Swagger接口文档 1. 前言 当接口开发完成,紧接着需要编写接口文档.传统的接口文档通常都是使用Word或者一些接口文档管理平台进行编写,但此类接口文档维护更新比较麻烦,每次 ...

  5. beego使用API自动化文档生成swagger时,routers目录下无法生成commentsRouter_controllers.go文件

    今天项目生成swagger时,按照官方文档操作,swagger目录和压缩包都正常创建,就连http://localhost:8080/swagger/也正常访问,但是 Try it out 接口时,就 ...

  6. android 手写字体识别,一种基于Android系统的手写数学公式识别及生成MathML的方法...

    专利名称:一种基于Android系统的手写数学公式识别及生成MathML的方法 技术领域: 本发明属于模式识别技术领域,涉及数学公式中字符间的空间结构分析,具体涉及一种基于Android系统的手写数学 ...

  7. pHp封装成vue,vue.js生成条形码的方法

    本文主要和大家分享vue.js生成条形码的方法,主要以代码的形式和大家分享,希望能帮助到大家. 1.下载插件npm install @xkeshi/vue-barcode //下载条形码插件 2.在m ...

  8. python读取文件名存到list_python读取文件名称生成list的方法

    下面为大家分享一篇python读取文件名称生成list的方法,具有很好的参考价值,希望对大家有所帮助.一起过来看看吧 经常需要读取某个文件夹下所有的图像文件. 我使用python写了个简单的代码,读取 ...

  9. php导出页面word,php导出生成word的方法_PHP

    php导出生成word的方法_PHP 本文实例讲述了php导出生成word的方法.分享给大家供大家参考,具体如下: PHP导出word (1)首先,预览html页面,示例化对象,定义要导出的数据(2) ...

最新文章

  1. edup无线网卡驱动安装linux,UBUNTU_15.0.4 usb无线网卡驱动安装方法
  2. 各国个人信息安全立法进度
  3. 使用GPG加密通讯,设置git提交验证密钥
  4. seo具体怎么优化-优化SEO的方法
  5. Unity 制造moba英雄联盟战争迷雾2
  6. 什么是云计算机服务,云平台是什么意思 云服务平台有哪些【详细介绍】
  7. U8 8.9 数据库置疑恢复方法
  8. 登录验证,如果输入错误次数超过3次,则锁定该账户
  9. HDU6397 Character Encoding 插板法+容斥
  10. linux基础--认识文件以及vi编辑器
  11. COSO企业风险管理综合框架主要关注8大层面的企业风险
  12. Eclipse中没有Servers或Dynamic Web Project的解决方案
  13. 利用计算机技术全面规划供应,英语翻译《物流术语》国家标准对供应链管理的定义:利用计算机网络技术全面规划供应链中的商流、物流、信息流、资金流等,并进行...
  14. 淘宝直播窄带高清技术
  15. Wechat----wxs
  16. 测试环境docker-swarm安装部署
  17. Win10 家庭版 升级至 专业版
  18. 10 道 OOP 方面的 Java 面试题,祝你跳槽涨薪一臂之力
  19. 计算机专业排名211大学排名,计算机专业大学排名,计算机专业强的211!
  20. 小米java面试题_小米java社招面试题分享,面经(一面二面)

热门文章

  1. [Java基础]ArrayList集合常用方法
  2. [蓝桥杯2016决赛]反幻方-next_permutation枚举
  3. Find them, Catch them POJ - 1703(种类并查集)
  4. linux jdk1.7 tomcat mysql_Linux环境搭建 jdk+tomcat+mysql
  5. 数据结构与算法--解决问题的方法-顺时针打印矩阵
  6. autowired用在static_java – @Autowired和static方法
  7. P4309 [TJOI2013]最长上升子序列 平衡树 + dp
  8. 2020牛客多校第1场I-1 or 2一般图最大匹配带花树
  9. CF1365G Secure Password(构造,交互,二进制分组)
  10. L Machining Disc Rotors