1. 程式人生 > >How to write your own Spring Boot starters

How to write your own Spring Boot starters

How to write your own Spring Boot starters

Introduction

In my first article, I would like to tell you how to deal with Spring Boot Configuration and Spring Boot Starters when you want to get your application more flexible due to the bootstrapping process.

Spring Boot provides a very useful tool that is used almost in every dependency of the project. If you look over the list of the dependencies Spring Boot project provides us, you will see a lot of them containing word “starter” in the name. This word means that the dependency provides a special way of configuration that is a part of the Spring Boot Framework functionality.

Spring Framework provides an ability to configure your beans using XML or Java Config way. The second one is the base of the Spring Boot’s starters mechanism. Every time your application is starting the framework looking over your base package and your project folders seeking @Configuration annotation to use it as a part of the initialization process. (You can learn much more about it in the official documentation). But it doesn’t find any configurations that are come with dependencies (Spring Framework ignores the configurations from the dependencies).

So, the starters mechanism is developed to get over that restriction and add the ability to configure beans just including dependencies. It may be very useful when you have a common library that provides some functionality that must be initialized and put into the DI container due to the application start process.