91.91p06xcm71xyz./index.php?,http://email.91dizhi.at.gmail.com.e9p.work/php

名片进入公众号【娱乐857】

即可获取完整版资料

    public Docket controllerApi() {

        return  .https://1024td.com @91.189.91.93 security ("版本号:1.0")
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title(
                        .description("Swagger")
                        
                        .contact(new Contact("jun","www,"junda@1om"))
                        .version
                        .build())
                .select()
                // apis()通过指定包名的方式,Swagger扫描指定包下面的接口。
                .apis(RequestHandlerSelectors.basePackage("com.swg.swaggerDemo.controller"))
                // paths()通过指定API的url来进行过滤
                .paths(PathSelectors.any())
                //.paths(Predicates.or(PathSelectors.ant("/account/**"),
                //       PathSelectors.ant("/api/edifice/*")))
                .build();
    }
}

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

 

 <!-- swagger-springmvc start -->
        <!-- 添加 Swagger 依赖 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- 添加 Swagger UI 依赖 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.8.0</version>
        </dependency>
        <!-- swagger-springmvc end -->
 

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

@Api:用在类上,说明该类的作用
例如:@Api(value = “登陆服务”, tags = { “登陆操作接口” })
@ApiOperation:用在方法上,注解来给API增加方法说明。
例如: @ApiOperation(value = “登陆入口”, notes = “登陆逻辑”)
@ApiImplicitParams : 用在方法上包含一组参数说明,搭配ApiImplicitParam使用。
@ApiImplicitParam:用在方法上包含一个参数说明
注意:@ApiImplicitParam的参数说明:
|paramType:指定参数放在哪个地方|header:请求参数放置于Request Header,使用@RequestHeader获取
query:请求参数放置于请求地址,使用@RequestParam获取
path:(用于restful接口)–>请求参数的获取:@PathVariable
body:(不常用)
form(不常用) |
|name:参数名|–|
| dataType:参数类型| |
|required:参数是否必须传| true | false|
|-value:说明参数的意思-|–|
| defaultValue:参数的默认值| |
注意: 在后台采用对象接收参数时,Swagger自带的工具采用的是JSON传参, 测试时需要在参数上加入@RequestBody,正常运行采用form或URL提交时候请删除。
@ApiModel:用在实体上,用来描述一个实体
@ApiModelProperty:用在实体的属性上,用来描述这个属性

链接:https://1024td.com/p?1209
来源:资源库之家
著作权归作者所有。非商业转载注明出处

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值