<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          【黑科技】mica-auto 2.0.3發(fā)布增強 spring boot 2.4 的支持

          共 2279字,需瀏覽 5分鐘

           ·

          2021-01-06 21:17

          一、簡介

          mica-auto (Spring boot stater開發(fā)利器)是 Spring cloud 微服務(wù)框架 Mica 中的一個基礎(chǔ)組件,用來生成 Spring boot starter 的一些基礎(chǔ)配置。

          二、原理

          mica auto 采用 Annotation Processor,它不是什么新技術(shù),在 jdk 1.6 就存在了。Annotation Processor 是 javac 的一個工具,它用來在編譯時掃描和處理注解。通過 Annotation Processor 可以獲取到注解和被注解對象的相關(guān)信息,然后根據(jù)注解自動生成Java代碼,省去了手動編寫,提高了編碼效率。大名鼎鼎的 Lombok 也是采用的該技術(shù)。

          三、功能

          • 自動生成 spring.factories、spring-devtools.properties 配置。
          • 生成 FeignClient 到 spring.factories 中,供 mica-cloud 中完成 Feign 自動化配置。
          • 生成 java spi 配置,需要添加 @AutoService 注解。
          注解spring.factories 或 Spi key
          @AutoContextInitializerApplicationContextInitializer
          @AutoListenerApplicationListener
          @AutoRunListenerSpringApplicationRunListener
          @AutoEnvPostProcessorEnvironmentPostProcessor
          @AutoFailureAnalyzerFailureAnalyzer
          @AutoConfigImportFilterAutoConfigurationImportFilter
          @AutoTemplateProviderTemplateAvailabilityProvider
          @AutoEnableCircuitBreakerEnableCircuitBreaker
          @AutoConfigDataLocationResolverConfigDataLocationResolver
          @AutoConfigDataLoaderConfigDataLoader
          @ComponentEnableAutoConfiguration
          @AutoIgnore忽略,不生成到 spring.factories
          @AutoService生成 java spi 配置

          四、2.x 更新記錄

          • 添加 AutoConfigDataLocationResolver。
          • 添加 AutoConfigDataLoader。
          • 添加 AutoEnableCircuitBreaker。
          • 升級 spring boot 到 2.4.1(非強制依賴,無兼容性問題)。

          五、使用

          注意: 如果你項目中使用了 Lombok 請將 mica-auto 的依賴放置到 Lombok 后面。

          5.1 maven

          <dependency>
          ??<groupId>net.dreamlugroupId>
          ??<artifactId>mica-autoartifactId>
          ??<version>2.0.3version>
          ??<scope>providedscope>
          dependency>

          5.2 gradle >= 5.x

          annotationProcessor("net.dreamlu:mica-auto:2.0.3")

          5.3 gradle < 5.x

          compileOnly?"net.dreamlu:mica-auto:2.0.3"

          5.4 java spi 示例:

          添加注解 @AutoService 指定 spi 接口 Processor.class。

          package?foo.bar;

          import?javax.annotation.processing.Processor;

          @AutoService(Processor.class)??
          public?class?MyProcessor?implements?Processor?
          {
          //?…
          }

          AutoService 將會自動生成 spi 的配置文件 META-INF/services/javax.annotation.processing.Processor 。內(nèi)容:

          foo.bar.MyProcessor

          六、mica 生態(tài)

          • mica (Spring cloud 微服務(wù)組件集): https://gitee.com/596392912/mica

          • mica-auto (Spring boot starter 利器): https://gitee.com/596392912/mica-auto

          • mica-weixin(jfinal weixin 的 spring boot starter):https://gitee.com/596392912/mica-weixin

          • mica-mqtt(基于 t-io 實現(xiàn)的 mqtt組件):https://gitee.com/596392912/mica-mqtt

          • Spring cloud 微服務(wù)內(nèi) http2 方案(h2c): https://gitee.com/596392912/spring-cloud-java11

          關(guān)注如夢技術(shù)碼云:https://gitee.com/596392912 ,更多 java 開源組件值得擁有。

          瀏覽 28
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  大香伊人中文字幕 | 欧美色综合一区二区三区 | 夜天干天干啦天干天天爽 | 高清免费在线中文Av | 2017AV天堂 |