Effortlessly Manage Spring Boot Config Files with mica-auto
This article introduces the mica-auto open‑source tool that uses Java annotation processing to automatically generate Spring Boot configuration files like spring.factories and AutoConfiguration.imports, and provides step‑by‑step instructions for integrating it into a Maven project.
After Spring Boot 2.7 stopped recommending the use of spring.factories, many developers find maintaining multiple configuration files cumbersome.
Open source project: mica-auto
mica-auto is an annotation‑processor‑based library that automatically generates Spring Boot configuration files such as spring.factories, spring-devtools.properties, and, from version 2.3 onward,
org.springframework.boot.autoconfigure.AutoConfiguration.imports.
GitHub address: https://github.com/lets-mica/mica-auto
How to use mica-auto
Step 1: Add the dependency to pom.xml (use provided scope and place it after Lombok if Lombok is present).
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>Step 2: Replace old configuration annotations with the newer ones, e.g., use @AutoConfiguration instead of @Configuration, so that the processor generates AutoConfiguration.imports rather than the legacy spring.factories.
@AutoConfiguration
@EnableConfigurationProperties(SwaggerProperties.class)
@ConditionalOnProperty(value = "springfox.documentation.enabled", havingValue = "true", matchIfMissing = true)
@Import({SwaggerUiConfiguration.class, SwaggerAuthorizationConfiguration.class, DocketConfiguration.class})
public class SwaggerAutoConfiguration {
@Bean
public DocketBeanFactoryPostProcessor docketBeanFactoryPostProcessor() {
return new DocketBeanFactoryPostProcessor();
}
}After recompiling the project, the appropriate configuration files are generated automatically.
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.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
