Starters

Spring Boot starters are sets of convenient dependency descriptors, and they only contain a dependency descriptor file, which is the pom.xml file. By convention, all official starters follow the naming pattern—spring-boot-starter-*, where * is a particular technology, for example, jdbc, and web. Spring Boot also has a core starter, which is spring-boot-starter. All other starters depend on this starter, mostly for the autoconfiguration support it provides. The core starter is also a dependency descriptor, and its autoconfiguration ability comes from its spring-boot-autoconfigure dependency. We will discuss autoconfiguration soon.

Let's take a close look at the spring-boot-starter-jdbc starter. In this starter's pom.xml file, listed dependencies include spring-boot-starter, HikariCP, and spring-jdbc. And, by adding this starter to our app, we don't need to worry about HikariCP, spring-jdbcor dependencies on which these two libraries depend. The build system you use, in our case, Maven, takes care of that.

Besides official starters, you can use custom starters provided by the community. For example, if you need to use MyBatis, you can use mybatis-spring-boot-starter. You can also create your own starters. All custom starters also need to depend on the core starter.

Due to the scope of this book, we're not going to discuss how to create a custom starter. If you're interested, you might want to take a look at the MyBatis starter (https://github.com/mybatis/spring-boot-starter).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.22.160