高版本springboot整合swagger

  • 这是我的springboot版本2.6: ![!\[Alt\](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIu](https://img-blog.csdnimg.cn/f3b9f7456e84432c9b339e69f9a32b9f.png)
  • 导入maven依赖(如果是高版本的别随便整合依赖会有问题):
  • 然后是swagger配置类
  • 然后在应用swagger模块的配置类中加上,这个一定得加,不然启动不了
  • 在你应用swagger的模块主启动一定要加上@ComponentScan("com.atguigu"),不然打开swagger什么都没有

第一次使用 高版本 springboot整合swagger存在一些问题,所以记录一下

这是我的springboot版本2.6:

导入maven依赖(如果是高版本的别随便整合依赖会有问题):

     <dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId><version>3.0.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>3.0.0</version></dependency>

然后是swagger配置类

@Configuration
@EnableSwagger2
public class SwaggerConfig {/*** swagger docket实例* @return*/@Beanpublic Docket docket(){return  new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).enable(true)              //是否激活swagger,如果是正式环境下,请把他设置为false.groupName("LittleFox")          //分组,可以设置多个docket.select().paths(PathSelectors.any()).build();}public ApiInfo apiInfo(){return new ApiInfoBuilder().title("LittleFox").description("谷粒商城swagger").version("1.0").termsOfServiceUrl("termsOfServiceUrl").contact(new Contact("name","url","email")).build();}
//    下面的是默认配置 apiInfo.default
//    static {//        DEFAULT = new ApiInfo("Api Documentation", "Api Documentation", "1.0", "urn:tos", DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList());
//    }
}

然后在应用swagger模块的配置类中加上,这个一定得加,不然启动不了

spring:mvc:pathmatch:matching-strategy: ant_path_matcher

在你应用swagger的模块主启动一定要加上@ComponentScan(“com.atguigu”),不然打开swagger什么都没有

@SpringBootApplication
@MapperScan("com.atguigu.gulimall.product.dao")
@ComponentScan("com.atguigu")    //给swagger指定地点
@EnableDiscoveryClientpublic class GulimallProductApplication {public static void main(String[] args) {SpringApplication.run(GulimallProductApplication.class,args);}
}

最后访问地址 http://localhost:10001/swagger-ui/ (端口号改成你自己的,其他不要变),就OK了

高版本springboot整合swagger相关推荐

  1. 解决高版本SpringBoot整合swagger时启动报错:Failed to start bean ‘documentationPluginsBootstrapper‘ 问题

    一.控制台的报错信息 2021-12-29 15:15:04 [main] ERROR org.springframework.boot.SpringApplication - Application ...

  2. springboot整合swagger(高版本)异常

    springboot整合swagger(高版本)异常 参考文章: (1)springboot整合swagger(高版本)异常 (2)https://www.cnblogs.com/chbyiming- ...

  3. 六、springboot整合swagger

    六.springboot整合swagger 简介 swagger 提供最强大,最易用的工具,以充分利用OpenAPI规范. 官网 : https://swagger.io/ 准备工作 pom.xml ...

  4. Springboot整合swagger指南

    Springboot整合swagger指南 1. 安装使用 1.1 下载依赖 <dependency><groupId>io.springfox</groupId> ...

  5. springboot整合swagger+knife4j

    springboot整合swagger+knife4j 参考网址: https://mp.weixin.qq.com/s/KlYj5JuJSJYQQ47mQu7b1w swagger配置参考文档 sw ...

  6. Springboot整合Swagger实战(一)

    Springboot整合Swagger实战(一) 记录一下自己在开发过程中,遇到的问题及安装环境的步骤(最讨厌安装环境了),希望可以帮到大家. 我在遇到问题的时候也是查找了好多文章,奈何呀,全是问题, ...

  7. springboot整合swagger+mybatisplus案例

    1.前后端分离的一个常用的文档接口swaggerui越来越受欢迎,方便了前端以及后端人员的测试 2.如下为springboot整合swagger和mybatispus案例的github地址:https ...

  8. Springboot整合Swagger UI 3.0.0 版本

    一.前言 在之前的项目中,以及提到了如何整合 Swagger UI 2 版本,包括导入jar包,编写配置文件,以及需要对应的springboot版本等. 链接如下:https://blog.csdn. ...

  9. Swagger自动接口文档生成框架————springboot整合swagger总结

    swagger简介: swagger是一款开源的api接口文档生成工具. Swagger的项目主页:https://swagger.io/    目前比较流行的做法是在代码中加入swagger相关的注 ...

最新文章

  1. Linux之远程登录、远程拷贝命令 ssh scp
  2. 嵌入式 linux 程序不能运行,嵌入式Linux中在开发板上/usr/bin目录下不能运行自己交叉编译的程序...
  3. 【JFreeChart】JFreeChart—输出柱形图
  4. php mysql搭建_PHP+MYSQL的搭建_MySQL
  5. redis采用序列化方案存对象
  6. 小甲鱼c语言 23课指针 数组和数组指针
  7. 【毕业设计】图像识别-人脸识别与疲劳检测 - python opencv
  8. 批量读取文件夹下所有excel文件里的内容,放入列表 把所有不管行列名如何excel合并成一个大的excel 批量读取excel,批量合并excel
  9. 哈尔滨啤酒集团有限公司盈利能力分析毕业设计
  10. Zabbix安装配置详解
  11. 【CF819C】Mister B and Beacons on Field 数学
  12. SSM疫情防控志愿者管理系统 志愿者服务信息系统 大学志愿者管理系统Java
  13. iftop监控网卡实时流量
  14. WIFI菠萝 strip-n-inject插件安装与使用
  15. 我的世界服务器物品无法合成,《我的世界》MC玩家无法合成的五大物品,最后一个已经被移除了!...
  16. wmf格式的图片如何通过Java转换成JPG格式的在页面上直接显示?
  17. 洛克人java下载_洛克人威利博士之谜
  18. unity 鼠标悬停事件
  19. 《等她找上门来》(最励志的爱情故事)
  20. 解决2023年PacketTracer 8.2登陆问题

热门文章

  1. 统信UOS 20 1050 记录一次openssl升级失败的排查过程
  2. 360极速浏览器下载tensorflow预训练模型问题
  3. 电脑扫描的文件怎么转换成word文档并修改
  4. 黑客讲故事:攻下隔壁女生路由器后,我都做了些什么
  5. 结构之美——优先队列三大结构(三)——Pairing Heap
  6. 清华本科生最高荣誉:图说十年特奖得主(附历年名单)
  7. 华为历史的几次重大管理变革
  8. 智能汽车信息安全进入“实战”时代 云驰未来助力车厂筑起安全防线
  9. 2017年有啥计算机病毒,2017年的计算机病毒有哪些
  10. 10分钟搭建局域网共享,3种方式,安全如此简单