How to Build a Custom Spring Boot Starter
My code library can be configured automatically using spring boot. It’s so cool.

As an enterprise java programmer, spring boot is so convenient that I can’t live without it. Its auto-configuration feature allows us to run your application in a few simple steps. Spring boot provides many starters to make your development faster and simpler. You don’t have to worry about complex configurations and class library references. Take developing a web service as an example.
- Using some starters dependencies such as
spring-boot-starterandspring-boot-starter-web - Add Webserver related parameters, such as
server.port - Start Server
Can we use spring boot to package our own starter library? The answer is yes. That is spring-boot, a framework with excellent extensibility.
Understanding Auto Configuration
Now let’s try to understand the principle of spring boot's auto-configuration function. To understand this part, you need to have a specific understanding of the life cycle of spring boot beans.
Spring boot uses the @EnableAutoConfigurationannotation to implement the auto-configuration. This annotation import the autoconfigurationImportSelectorclass, which resolves META-INF/spring.factories file when spring boot starts, and then all configuration classes in the file are loaded into memory and registered in the spring container. The spring.factories file is like this.
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.autoconfigure.aop.AopAutoConfigurationAfter the BeanFactory is created, spring boot will call a specific beanFactoryPostProcessor--ConfigurationClassPostProcessorto complete the configuration classes resolution. The purpose is to register the methods modified by the @Bean annotation in the configuration class in the spring container as special beans. The beans defined in the configuration class are managed by the spring container, and we can do anything with spring. This is the auto configuration principle of spring boot.
Create a Custom Starter Library
First, you need to create a spring project. Here is the pom.xml of my example.







