Backend Development 5 min read

How mica-auto Simplifies Spring Boot Starter Creation with Annotation Processors

The article introduces mica-auto, a Spring Cloud component that uses annotation processing to automatically generate starter configurations, SPI entries, and Feign client setups, and provides usage examples for Maven and Gradle along with recent updates.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
How mica-auto Simplifies Spring Boot Starter Creation with Annotation Processors

1. Introduction

mica-auto (Spring boot starter tool) is a basic component of the Mica Spring Cloud microservice framework, used to generate basic configuration for Spring boot starters.

2. Principle

mica-auto uses an Annotation Processor, a feature present since JDK 1.6. The processor scans annotations at compile time and can generate Java code automatically, similar to Lombok.

3. Features

Automatically generate spring.factories and spring-devtools.properties configurations.

Generate FeignClient entries into spring.factories for automatic Feign configuration in mica-cloud.

Generate Java SPI configuration by adding the

@AutoService

annotation.

4. 2.x Update Log

Added AutoConfigDataLocationResolver.

Added AutoConfigDataLoader.

Added AutoEnableCircuitBreaker.

Upgraded Spring Boot to 2.4.1 (non‑mandatory, no compatibility issues).

5. Usage

Note:

If your project uses Lombok, place the mica-auto dependency after Lombok.

5.1 Maven

<code>&lt;dependency&gt;
  &lt;groupId&gt;net.dreamlu&lt;/groupId&gt;
  &lt;artifactId&gt;mica-auto&lt;/artifactId&gt;
  &lt;version&gt;2.0.3&lt;/version&gt;
  &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
</code>

5.2 Gradle ≥ 5.x

<code>annotationProcessor("net.dreamlu:mica-auto:2.0.3")</code>

5.3 Gradle < 5.x

<code>compileOnly "net.dreamlu:mica-auto:2.0.3"</code>

5.4 Java SPI example

Add the

@AutoService

annotation and specify the SPI interface

Processor.class

.

<code>package foo.bar;

import javax.annotation.processing.Processor;

@AutoService(Processor.class)
public class MyProcessor implements Processor {
    // …
}
</code>

AutoService will automatically generate the SPI configuration file

META-INF/services/javax.annotation.processing.Processor

containing:

<code>foo.bar.MyProcessor</code>

6. Mica Ecosystem

mica (Spring Cloud microservice component set): https://gitee.com/596392912/mica

mica-auto (Spring boot starter tool): https://gitee.com/596392912/mica-auto

mica-weixin (JFinal Weixin Spring boot starter): https://gitee.com/596392912/mica-weixin

mica-mqtt (MQTT component based on t‑io): https://gitee.com/596392912/mica-mqtt

Spring Cloud HTTP/2 solution (h2c): https://gitee.com/596392912/spring-cloud-java11

Follow the author’s Gitee page for more Java open‑source components: https://gitee.com/596392912

MicroservicesBackend DevelopmentSpring BootAnnotation ProcessorJava SPIMica
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.