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

springboot 集成swagger ui

时间:2018-01-07 14:04:15      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:https   class   链接   ring   api   www   注释   方法   tco   

1. 添加依赖

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

2. 启动swagger ui注解

@SpringBootApplication
@EnableSwagger2
public class Main {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Main.class, args);
    }
}

3.添加 controller注解

@RestController
@RequestMapping("/user")
@Api("swagger ui 注释 api 级别")
public class HelloWorldController {

    @ApiOperation("swagger ui 注释 方法级别")
    @RequestMapping(value="/hello",method=RequestMethod.GET)
    public  String hello() {
        String data = "Never trouble untill trouble troubles you. Some one told me some years ago.";
        return data;
    }
}

4. swagger ui 链接: localhost:8080//swagger-ui.html (默认)

技术分享图片

 

参考这里

 

springboot 集成swagger ui

标签:https   class   链接   ring   api   www   注释   方法   tco   

原文地址:https://www.cnblogs.com/pangkang/p/8227467.html

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