Backend Development 4 min read

Automate Spring Boot Starter Setup with mica-auto

The mica-auto component of the Mica Spring Cloud framework provides a set of tools that automatically generate essential Spring Boot starter files such as spring.factories, spring‑devtools.properties, and Java SPI configurations, simplifying multi‑module backend projects and supporting annotations like @AutoService for seamless integration.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Automate Spring Boot Starter Setup with mica-auto

Introduction

mica-auto is a core component of the Spring Cloud microservice framework Mica, used to generate basic configurations for Spring Boot starters.

Features

Generate

spring.factories

.

Generate

spring-devtools.properties

.

Add FeignClient entries to

spring.factories

for automatic Feign configuration in mica-cloud.

Generate Java SPI configuration, requiring the

@AutoService

annotation.

@AutoContextInitializer: ApplicationContextInitializer

@AutoListener: ApplicationListener

@AutoRunListener: SpringApplicationRunListener

@AutoEnvPostProcessor: EnvironmentPostProcessor

@AutoFailureAnalyzer: FailureAnalyzer

@Component: EnableAutoConfiguration

@AutoService: Java SPI configuration

Change Log

Added support for

SpringApplicationRunListener

.

Added support for

EnvironmentPostProcessor

.

Upgraded Spring Boot to

2.2.6.RELEASE

.

Usage

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

Maven

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

Gradle ≥ 5.x

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

Gradle < 5.x

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

Java SPI Example

<code>package foo.bar;

import javax.annotation.processing.Processor;

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

The

AutoService

annotation automatically generates the SPI configuration file

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

with the content:

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

Usage Scenarios

Spring Boot starter development tool that automatically generates

spring.factories

and

spring-devtools.properties

configurations.

Automatic configuration for sub‑modules in multi‑module projects where package names differ (not recommended for the main project).

Automatic generation of Java SPI extension configurations.

backend developmentSpring BootAuto‑ConfigurationJava 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.