码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Boot 使用 Swagger UI

时间:2018-04-30 14:30:55      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:cat   ica   pre   main   group   地址   api   host   csdn   

引入pom依赖:

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.7.0</version>
        </dependency>

到GitHub https://github.com/swagger-api/swagger-ui 下载项目,dist目录拷贝出来直接放到资源路径.

技术分享图片

技术分享图片

index.html 即为api页面

然后在Spring Boot 启动类加上注解 @EnableSwagger2

@SpringBootApplication
@EnableSwagger2
public class NeteaseApplication {
    public static void main(String[] args) {
        SpringApplication.run(NeteaseApplication.class, args);
    }
}

Api 地址:http://localhost:8080/api/index (地址由存放的资源路径文件夹决定)

Api-json:http://localhost:8080/v2/api-docs

技术分享图片

 

Swagger2 常用注解:https://blog.csdn.net/u014231523/article/details/76522486

Spring Boot 使用 Swagger UI

标签:cat   ica   pre   main   group   地址   api   host   csdn   

原文地址:https://www.cnblogs.com/cearnach/p/8973499.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!