使用mica-auto生成Spring boot starter配置

mica-auto 代碼自動生成

mica-autoSpring cloud 微服務框架 Mica 中的一個基礎組件,用來生成 Spring boot starter 的一些基礎配置。html

版本更新記錄:https://github.com/lets-mica/mica-auto/blob/master/CHANGELOG.md
最新版本:https://mvnrepository.com/artifact/net.dreamlu/mica-autogit

使用場景

主要是用來避免 Spring boot 主項目包同 子項目或者子模塊 包不一致,避免包掃描不到的問題。github

  • 自定義 spring boot starter
  • 多模塊項目中的子項目(不建議主項目添加 mica-auto)。

功能

  1. 生成 spring.factories
  2. 生成 spring-devtools.properties
  3. 生成 FeignClientspring.factories 中,供 mica-pro 中完成 Feign 自動化配置。

使用

注意: 若是你項目中使用了 Lombok 請將 mica-auto 的依賴放置到 Lombok 後面。spring

maven

<dependency>
  <groupId>net.dreamlu</groupId>
  <artifactId>mica-auto</artifactId>
  <version>${version}</version>
  <scope>provided</scope>
</dependency>

gradle >= 5.x

annotationProcessor("net.dreamlu:mica-auto:${version}")

gradle < 5.x

compileOnly "net.dreamlu:mica-auto:${version}"

圖示

添加依賴

mica-auto-001.png

依賴構建

當執行 mvn package 或者 gradle build 時 就會生成相關配置。

mica-auto-002.jpg

mica-auto-003.png框架

原理

掃描 @Component,自動生成相應的配置,支持組合註解。maven

開源協議

LGPL(GNU Lesser General Public Licenseide

源碼地址

參考

Google Auto: https://github.com/google/auto微服務

Spring 5 - spring-context-indexer:https://github.com/spring-projects/spring-framework/tree/master/spring-context-indexergradle

相關文章
相關標籤/搜索