How mica-auto Automates Spring Boot Starter Configuration with Annotation Processors
This article explains the mica-auto library, which uses Java annotation processing to automatically generate Spring Boot starter configurations, streamline component registration, and simplify multi‑module Spring Cloud projects, while providing Maven and Gradle integration details and recent change logs.
Introduction
mica-auto works by leveraging Java Annotation Processor technology to automatically generate essential Spring Boot starter configurations during compilation. It is widely used in Spring Cloud's core component Mica as well as in projects like pig and Springblade.
Features
Generates classes annotated with @Component into spring.factories.
Creates spring-devtools.properties.
Combines spring-boot-configuration-processor and spring-boot-autoconfigure-processor to avoid excessive dependencies.
Generates @FeignClient interfaces into spring.factories for automatic Feign configuration in Mica.
Change Log
[1.1.0] - 2019-05-24
Additions
Add @AutoContextInitializer supporting org.springframework.context.ApplicationContextInitializer.
Add @AutoListener supporting org.springframework.context.ApplicationListener.
Add @AutoFailureAnalyzer supporting org.springframework.boot.diagnostics.FailureAnalyzer.
Dependency Upgrades
Upgrade Gradle to 5.4.1.
Upgrade Google Auto to 1.0-rc5.
Upgrade Lombok to 1.18.8.
Upgrade Spring Boot to 2.1.5.RELEASE.
Usage
Note: If your project uses Lombok, place the mica-auto dependency after Lombok.
Maven
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>Gradle >= 5.x
annotationProcessor("net.dreamlu:mica-auto:1.1.0")Gradle < 5.x
compileOnly "net.dreamlu:mica-auto:1.1.0"Usage Scenarios
The library helps avoid inconsistencies between the main Spring Boot project's package and sub‑project or module packages, preventing class‑scanning issues.
Typical scenarios include:
Custom Spring Boot starter development.
Multi‑module projects where sub‑projects should not add the dependency to the main project.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
