Spring Boot 使用 Swagger UI

引入pom依赖:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</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

posted @ 2018-04-30 13:28  cearnach  阅读(162)  评论(0编辑  收藏  举报