建立本身的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

相關文章
相關標籤/搜索