Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring Boot Cookbook

You're reading from   Spring Boot Cookbook Over 35 recipes to help you build, test, and run Spring applications using Spring Boot

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781785284151
Length 206 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alex Antonov Alex Antonov
Author Profile Icon Alex Antonov
Alex Antonov
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with Spring Boot FREE CHAPTER 2. Configuring Web Applications 3. Web Framework Behavior Tuning 4. Writing Custom Spring Boot Starters 5. Application Testing 6. Application Packaging and Deployment 7. Health Monitoring and Data Visualization Index

Using a Spring Boot template and starters

Spring Boot comes with over 40 different starter modules, which provide ready-to-use integration libraries for many different frameworks, such as database connections that are both relational and NoSQL, web services, social network integration, monitoring libraries, logging, template rendering, and the list just keeps going. While it is not practically feasible to cover every single one of these components, we will go over the important and popular ones in order to get an idea of the realm of possibilities and the ease of application development that Spring Boot provides us with.

How to do it…

We will start with creating a basic simple project skeleton and Spring Boot will help us in this:

  1. Let's head over to http://start.spring.io.
  2. Fill out a simple form with the details about our project.
  3. Clicking on Generate Project will download a premade project skeleton for us to start with.

How it works…

You will see the Project Dependencies section, where we can choose the kind of functionalities that our application will perform: will it connect to a database, will it have a web interface, do we plan to integrate with any of the social networks, provide runtime operational support capabilities, and so on. By selecting the desired technologies, the appropriate starter libraries will be added automatically to the dependency list of our pregenerated project template.

Before we proceed with the generation of our project, let's go over exactly what a Spring Boot starter is and the benefits it provides us with.

Spring Boot aims to simplify the process of getting started with an application creation. Spring Boot starters are bootstrap libraries that contain a collection of all the relevant transitive dependencies that are needed to start a particular functionality. Each starter has a special file, which contains the list of all the provided dependencies—spring.provides. Let's take a look at the following link for a spring-boot-starter-test definition as an example:

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-starters/spring-boot-starter-test/src/main/resources/META-INF/spring.provides

Here we will see the following:

provides: spring-test, spring-boot, junit, mockito, hamcrest-library

This tells us that by including spring-boot-starter-test in our build as a dependency, we will automatically get spring-test, spring-boot, junit, mockito, and hamcrest-library. These libraries will provide us with all the necessary things in order to start writing application tests for the software that we will develop, without needing to manually add these dependencies to the build file individually.

With more than 40 starters provided and with the ongoing community additions increasing the list, it is very likely that in case we find ourselves with the need to integrate with a fairly common or popular framework, there is already a starter out there that we can use.

The following table shows you the most notable ones so as to give you an idea of what is available:

Starter

Description

spring-boot-starter

This is the core Spring Boot starter that provides you with all the foundational functionalities. It is depended upon by all other starters, so there is no need to declare it explicitly.

spring-boot-starter-actuator

This starter provides you with a functionality to monitor, manage an application, and audit it.

spring-boot-starter-jdbc

This starter provides you with a support to connect and use JDBC databases, connection pools, and so on.

spring-boot-starter-data-jpa

The JPA starter provides you with needed libraries in order to use Java Persistence API such as Hibernate, and others.

spring-boot-starter-data-*

Collection of data-* family starter components providing support for a number of data stores such as MongoDB, Data-Rest, or Solr.

spring-boot-starter-security

This brings in all the needed dependencies for spring-security.

spring-boot-starter-social-*

This provides you with integration with Facebook, Twitter, and LinkedIn.

spring-boot-starter-test

This is a starter that contains the dependencies for spring-test and assorted testing frameworks such as JUnit and Mockito among others.

spring-boot-starter-web

This gives you all the needed dependencies for web application development. It can be complimented with spring-boot-starter-hateoas, spring-boot-starter-websocket, spring-boot-starter-mobile, or spring-boot-starter-ws, and assorted template rendering starters such as sping-boot-starter-thymeleaf or spring-boot-starter-mustache.

You have been reading a chapter from
Spring Boot Cookbook
Published in: Sep 2015
Publisher: Packt
ISBN-13: 9781785284151
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image