swagger多包扫描

swagger的搭建与使用

关于搭建与使用,如果大家还不清楚的话,可以去看看我的上一篇文章

swagger 多包扫描

在开发中我们可能不需要扫描全部的包,可能只需要扫描部分包

环境

现在在swagger包下有分别有controller1和controller2两个包,现在只需要扫描这两个包,但又不能把swagger包下全部内容扫描

重写包扫描方法

由于使用RequestHandlerSelectors.basePackage()方法只能扫描一个包而不能扫描多个包,所以这里重写了包扫描方法


package com.springboot.swagger.configs;


import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(basePackage("com.white.swagger.controller1"+splitor+"com.white.swagger.controller2
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值