SpringBoot简易整合Swagger2
添加依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
springboot中开启swagger
在启动类上添加注解@EnableSwagger2
@EnableSwagger2
@SpringBootApplication()
public class TestServiceApplication {
public static void main(String[] args) {
SpringApplication.run(TestServiceApplication.class, args);
}
}
如果不在启动类上添加注解打开swagger页面时会提示Unable to infer base url错误
配置文件
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
访问swagger
默认地址为:127.0.0.1:8080/xxx-service/swagger-ui.html
本文作者:无情歌神
本文链接:https://www.cnblogs.com/zjq97/p/16083132.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步