Chapter 2. Spring Boot for Microservices
Spring Boot is an opinionated Java framework for building microservices based on the Spring dependency injection framework. Spring Boot facilitates creation of microservices through reduced boilerplate, configuration, and developer friction. This is a similar approach to the two other frameworks we’ll look at.
Advantages of Spring Boot
Spring Boot offers the following advantages in comparison to the Spring framework:
-
Favoring automatic, conventional configuration by default
-
Curating sets of popular starter dependencies for easier consumption
-
Simplifying application packaging
-
Baking in application insight (e.g., metrics and environment info)
Simplified Configuration
Spring historically was a nightmare to configure. Although the framework
improved upon other high-ceremony component models (EJB 1.x, 2.x, etc.),
it did come along with its own set of heavyweight usage patterns.
Namely, Spring required a lot of XML configuration and a deep
understanding of the individual beans needed to construct JdbcTemplates
,
JmsTemplates
, BeanFactory
lifecycle hooks, servlet listeners, and many other components. In fact, writing a simple “Hello World” with Spring MVC required understanding of DispatcherServlet and a whole host of Model–View–Controller classes. Spring Boot aims to eliminate all of this boilerplate configuration with some implied conventions and simplified annotations—although, you can still finely tune the underlying beans if you ...
Get Microservices for Java Developers, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.