首页 > 其他 > 详细

Swagger学习(一、入门)

时间:2019-11-23 10:51:51      阅读:150      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 技术分享图片

 

 技术分享图片

 

简单 入门(效果)

技术分享图片

 

 技术分享图片

 

 SwaggerConfig.class

@Configuration   //变成配置文件
@EnableSwagger2  //开启swagger2
public class SwaggerConfig {
}

 pom.xml

<dependencies>
        <!--swagger-->
        <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>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

 HelloController.class

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello swagger";
    }
}

 不要忘记Swagger的配置文件 SwaggerConfig.class就好了

Swagger学习(一、入门)

原文:https://www.cnblogs.com/shiguanzui/p/11914188.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!