高版本springboot整合swagger
高版本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相关推荐
- 解决高版本SpringBoot整合swagger时启动报错:Failed to start bean ‘documentationPluginsBootstrapper‘ 问题
一.控制台的报错信息 2021-12-29 15:15:04 [main] ERROR org.springframework.boot.SpringApplication - Application ...
- springboot整合swagger(高版本)异常
springboot整合swagger(高版本)异常 参考文章: (1)springboot整合swagger(高版本)异常 (2)https://www.cnblogs.com/chbyiming- ...
- 六、springboot整合swagger
六.springboot整合swagger 简介 swagger 提供最强大,最易用的工具,以充分利用OpenAPI规范. 官网 : https://swagger.io/ 准备工作 pom.xml ...
- Springboot整合swagger指南
Springboot整合swagger指南 1. 安装使用 1.1 下载依赖 <dependency><groupId>io.springfox</groupId> ...
- springboot整合swagger+knife4j
springboot整合swagger+knife4j 参考网址: https://mp.weixin.qq.com/s/KlYj5JuJSJYQQ47mQu7b1w swagger配置参考文档 sw ...
- Springboot整合Swagger实战(一)
Springboot整合Swagger实战(一) 记录一下自己在开发过程中,遇到的问题及安装环境的步骤(最讨厌安装环境了),希望可以帮到大家. 我在遇到问题的时候也是查找了好多文章,奈何呀,全是问题, ...
- springboot整合swagger+mybatisplus案例
1.前后端分离的一个常用的文档接口swaggerui越来越受欢迎,方便了前端以及后端人员的测试 2.如下为springboot整合swagger和mybatispus案例的github地址:https ...
- Springboot整合Swagger UI 3.0.0 版本
一.前言 在之前的项目中,以及提到了如何整合 Swagger UI 2 版本,包括导入jar包,编写配置文件,以及需要对应的springboot版本等. 链接如下:https://blog.csdn. ...
- Swagger自动接口文档生成框架————springboot整合swagger总结
swagger简介: swagger是一款开源的api接口文档生成工具. Swagger的项目主页:https://swagger.io/ 目前比较流行的做法是在代码中加入swagger相关的注 ...
最新文章
- Linux之远程登录、远程拷贝命令 ssh scp
- 嵌入式 linux 程序不能运行,嵌入式Linux中在开发板上/usr/bin目录下不能运行自己交叉编译的程序...
- 【JFreeChart】JFreeChart—输出柱形图
- php mysql搭建_PHP+MYSQL的搭建_MySQL
- redis采用序列化方案存对象
- 小甲鱼c语言 23课指针 数组和数组指针
- 【毕业设计】图像识别-人脸识别与疲劳检测 - python opencv
- 批量读取文件夹下所有excel文件里的内容,放入列表 把所有不管行列名如何excel合并成一个大的excel 批量读取excel,批量合并excel
- 哈尔滨啤酒集团有限公司盈利能力分析毕业设计
- Zabbix安装配置详解
- 【CF819C】Mister B and Beacons on Field 数学
- SSM疫情防控志愿者管理系统 志愿者服务信息系统 大学志愿者管理系统Java
- iftop监控网卡实时流量
- WIFI菠萝 strip-n-inject插件安装与使用
- 我的世界服务器物品无法合成,《我的世界》MC玩家无法合成的五大物品,最后一个已经被移除了!...
- wmf格式的图片如何通过Java转换成JPG格式的在页面上直接显示?
- 洛克人java下载_洛克人威利博士之谜
- unity 鼠标悬停事件
- 《等她找上门来》(最励志的爱情故事)
- 解决2023年PacketTracer 8.2登陆问题