使用mica-auto生成Spring boot starter配置
mica-auto 代码自动生成
mica-auto 是 Spring cloud 微服务框架 Mica 中的一个基础组件,用来生成 Spring boot starter 的一些基础配置。
版本更新记录:https://github.com/lets-mica/mica-auto/blob/master/CHANGELOG.md
最新版本:https://mvnrepository.com/artifact/net.dreamlu/mica-auto
使用场景
主要是用来避免 Spring boot 主项目包同 子项目或者子模块 包不一致,避免包扫描不到的问题。
- 自定义
spring boot starter。 - 多模块项目中的
子项目(不建议主项目添加mica-auto)。
功能
- 生成
spring.factories - 生成
spring-devtools.properties - 生成
FeignClient到spring.factories中,供mica-pro中完成Feign自动化配置。
使用
注意: 如果你项目中使用了 Lombok 请将 mica-auto 的依赖放置到 Lombok 后面。
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}"
图示
添加依赖

依赖构建
当执行 mvn package 或者 gradle build 时 就会生成相关配置。

原理
扫描 @Component,自动生成相应的配置,支持组合注解。
开源协议
LGPL(GNU Lesser General Public License)
用户权益
- 允许以引入不改源码的形式免费用于学习、毕设、公司项目、私活等。
- 特殊情况修改代码,但仍然想闭源需经过作者同意。
- 参考请注明:参考 mica-atuo:https://github.com/lets-mica/mica-auto
参考
Google Auto: https://github.com/google/auto
Spring 5 - spring-context-indexer:https://github.com/spring-projects/spring-framework/tree/master/spring-context-indexer