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
@Componentinto
spring.factories.
Creates
spring-devtools.properties.
Combines
spring-boot-configuration-processorand
spring-boot-autoconfigure-processorto avoid excessive dependencies.
Generates
@FeignClientinterfaces into
spring.factoriesfor automatic Feign configuration in Mica.
Change Log
[1.1.0] - 2019-05-24
Additions
Add
@AutoContextInitializersupporting
org.springframework.context.ApplicationContextInitializer.
Add
@AutoListenersupporting
org.springframework.context.ApplicationListener.
Add
@AutoFailureAnalyzersupporting
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-autodependency after Lombok.
Maven
<code><dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency></code>Gradle >= 5.x
<code>annotationProcessor("net.dreamlu:mica-auto:1.1.0")</code>Gradle < 5.x
<code>compileOnly "net.dreamlu:mica-auto:1.1.0"</code>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.
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.