内容简介:一、简介 mica-auto (Spring boot stater开发利器)是 Spring cloud 微服务框架 Mica 中的一个基础组件,用来生成 Spring boot starter 的一些基础配置。 二、功能 生成 spring.factories。 生成 spring-devtool...
一、简介
mica-auto (Spring boot stater开发利器)是 Spring cloud 微服务框架 Mica 中的一个基础组件,用来生成 Spring boot starter 的一些基础配置。
二、功能
-
- 生成 spring.factories。
- 生成 spring-devtools.properties
- 生成 FeignClient 到 spring.factories 中,供 mica-cloud 中完成 Feign 自动化配置。
- 生成 java Spi 配置,需要添加 @AutoService 注解。
注解 | spring.factories 或 Spi key |
@AutoContextInitializer | ApplicationContextInitializer |
@AutoListener | ApplicationListener |
@AutoRunListener | SpringApplicationRunListener |
@AutoEnvPostProcessor | EnvironmentPostProcessor |
@AutoFailureAnalyzer | FailureAnalyzer |
@AutoConfigImportFilter | AutoConfigurationImportFilter |
@AutoTemplateProvider | TemplateAvailabilityProvider |
@AutoEnableCircuitBreaker | EnableCircuitBreaker |
@AutoConfigDataLocationResolver | ConfigDataLocationResolver |
@AutoConfigDataLoader | ConfigDataLoader |
@Component | EnableAutoConfiguration |
@AutoIgnore | 忽略,不生成到 spring.factories |
@AutoService | java Spi 生成配置 |
三、变更记录
- 添加 AutoConfigDataLocationResolver。
- 添加 AutoConfigDataLoader
四、使用
注意: 如果你项目中使用了 Lombok 请将 mica-auto 的依赖放置到 Lombok 后面。
4.1 maven
<dependency> <groupId>net.dreamlu</groupId> <artifactId>mica-auto</artifactId> <version>2.0.3</version> <scope>provided</scope> </dependency>
4.2 gradle >= 5.x
annotationProcessor("net.dreamlu:mica-auto:2.0.3")
4.3 gradle < 5.x
compileOnly "net.dreamlu:mica-auto:2.0.3"
4.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 。内容:
foo.bar.MyProcessor
五、使用场景
- Spring boot starter 开发利器,自动生成 spring.factories、spring-devtools.properties 配置。
- 多模块项目中的子项目,包名不同时的自动配置(主项目不建议添加)。
- java spi 扩展自动生成配置。
建议关注如梦技术码云: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 实现的 mqtt组件):https://gitee.com/596392912/mica-mqtt
-
Spring cloud 微服务 http2 方案(h2c): https://gitee.com/596392912/spring-cloud-java11
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 地开发环境搭建利器--vagrant
- 前端开发利器:Wep Replay
- 布隆过滤器你值得拥有的开发利器
- GitHub 推出开发者赚钱新利器,100% 全给开发者!
- 微服务解决方案 Go微服务开发利器
- 前端开发利器 WebStorm 发布 2017.3.3 正式版本
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Numerical Recipes 3rd Edition
William H. Press、Saul A. Teukolsky、William T. Vetterling、Brian P. Flannery / Cambridge University Press / 2007-9-6 / GBP 64.99
Do you want easy access to the latest methods in scientific computing? This greatly expanded third edition of Numerical Recipes has it, with wider coverage than ever before, many new, expanded and upd......一起来看看 《Numerical Recipes 3rd Edition》 这本书的介绍吧!