建立本身的Spring Boot starter

Spring Boot starter 的组件

  • autoconfigure
  • starter

autoconfigure模块

包含自动配置的代码git

starter模块

包含autoconfigure模块所依赖的包以及通用的包github

命名

  • 不要以 spring-boot 开头
  • xxx-spring-boot-autoconfigure 及 xxx-spring-boot-starter
  • autoconfigure 和 starter 合在一块儿 xxx-spring-boot-starter
  • configuration key 不要和Spring Boot使用的冲突
  • 为了更好的支持IDE(properties文件中自动提示)须要在autoconfigure模块下提供META-INF/spring-configuration-metadata.json

swagger-spring-boot-starter 实例

  • swagger-spring-boot-starter
  • swaager-spring-boot-autoconfigure

swagger 配置提取

  • documentationType:[name:"",version:""]# 取值:swagger 1.2;swagger 2.0;spring-web 1.0
  • pathMapping # 映射的url
  • basePackage # 扫描的包
  • excludePath # 排除的url
  • title # 文档标题
  • description # 文档描述
  • version # 版本号
  • scheme # 安全模式:key,oauth
  • param.name # 参数名称
  • param.type # 参数传递位置
  • oauth2.clientId # oauth2模式的 clientId
  • oauth2.secretId # oauth2模式的 secretId
  • oauth2.realm # oauth2模式的 secretId
  • oauth2.scope # oauth2模式的 scope
  • oauth2.scope.name # oauth2模式的 scope 名称
  • oauth2.scope.description # oauth2模式的 scope描述
  • oauth2.grantType #受权类型
  • oauth2.grantType.name # 受权类型,取值:authorization_code、client_credentials、password
  • oauth2.grantType.tokenUrl # 获取token的 URL
  • oauth2.grantType.authorizeUrl #认证URL

代码swagger-spring-bootweb

参考

mybatis-spring-boot-starterspring

相关文章
相关标签/搜索