springfox源码_springfox 源码分析(四) 配置类初始化

时间:2019-5-23 12:46:50

地点:单位、家中

@EnableSwagger2

有了二三章的理解,此时我们再来看EnableSwagger2注解的内容

@Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)

@Target(value = { java.lang.annotation.ElementType.TYPE })

@Documented

@Import({Swagger2DocumentationConfiguration.class})

public @interface EnableSwagger2 {

}

Swagger2DocumentationConfiguration

该注解没啥好说的,最终是导入Swagger2DocumentationConfiguration的配置类

@Configuration

@Import({ SpringfoxWebMvcConfiguration.class, SwaggerCommonConfiguration.class })

@ComponentScan(basePackages = {

"springfox.documentation.swagger2.mappers"

})

@ConditionalOnWebApplication

public class Swagger2DocumentationConfiguration {

此处的@ComponentScan注解,扫描了springfox.documentation.swagger2.mappers包路径

Mappers

该包路径下包含了众多运用MapStruct组件自动生成的Mapper实体类转换关系,通过扫描注解,自动注入到Spring的容器中

关于MapStruct组件的使用,可参考:springfox 源码分析(二) 初探mapstruct

主要包括如下:

LicenseMapper

ModelMapper

ParameterMapper

SecurityMapper

SerivceModelToSwagger2Mapper

VendorExtensionsMapper

每个Mapper接口都有一个实现类MapperImpl,实现类通过@Component注解注入到Spring的容器中

最重要的是SerivceModelToSwagger2Mapper这个Mapper

该类的作用会聚合使用Model、Parameter、License等Mapper,将springfox中的对象转化为Swagger标准的对象,包括Swagger

@Generated(

value = "org.mapstruct.ap.MappingProcessor&#

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值