学不动了就进厂|

无情歌神

园龄:6年9个月粉丝:3关注:1

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 中国大陆许可协议进行许可。

posted @   无情歌神  阅读(82)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开