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.
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
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>Gradle ≥ 5.x
annotationProcessor("net.dreamlu:mica-auto:1.2.1")Gradle < 5.x
compileOnly "net.dreamlu:mica-auto:1.2.1"Java SPI Example
package foo.bar;
import javax.annotation.processing.Processor;
@AutoService(Processor.class)
public class MyProcessor implements Processor {
// …
}The AutoService annotation automatically generates the SPI configuration file META-INF/services/javax.annotation.processing.Processor with the content:
foo.bar.MyProcessorUsage 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.
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.
