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.factoriesfor automatic Feign configuration in mica-cloud.
Generate Java SPI configuration, requiring the
@AutoServiceannotation.
@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><dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency></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
AutoServiceannotation automatically generates the SPI configuration file
META-INF/services/javax.annotation.processing.Processorwith the content:
<code>foo.bar.MyProcessor</code>Usage Scenarios
Spring Boot starter development tool that automatically generates
spring.factoriesand
spring-devtools.propertiesconfigurations.
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.
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.