Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Spring Boot 2.0

You're reading from   Learning Spring Boot 2.0 Simplify the development of lightning fast applications based on microservices and reactive programming

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781786463784
Length 370 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Greg L. Turnquist Greg L. Turnquist
Author Profile Icon Greg L. Turnquist
Greg L. Turnquist
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Quick Start with Java FREE CHAPTER 2. Reactive Web with Spring Boot 3. Reactive Data Access with Spring Boot 4. Testing with Spring Boot 5. Developer Tools for Spring Boot Apps 6. AMQP Messaging with Spring Boot 7. Microservices with Spring Boot 8. WebSockets with Spring Boot 9. Securing Your App with Spring Boot 10. Taking Your App to Production with Spring Boot

Spring Boot starters

No application is complete without specifying dependencies. A valuable feature of Spring Boot is its virtual packages. These are published packages that don't contain any code, but simply list other dependencies instead.

The following code shows all the dependencies we selected on the Spring Initializr site:

    dependencies { 
      compile('org.springframework.boot:spring-boot-starter-data-
mongodb-reactive') compile('org.springframework.boot:spring-boot-starter-thymeleaf') compile('org.springframework.boot:spring-boot-starter-webflux') compile('org.projectlombok:lombok') compile('de.flapdoodle.embed:de.flapdoodle.embed.mongo') testCompile('org.springframework.boot:spring-boot-starter-test') }

You might have noticed that most of these packages are Spring Boot starters:

  • spring-boot-starter-data-mongodb-reactive pulls in Spring Data MongoDB with the reactive bits enabled
  • spring-boot-starter-thymeleaf pulls in the Thymeleaf template engine
  • spring-boot-starter-webflux pulls in Spring WebFlux, Jackson JSON support, and embedded Netty

These starter packages allow us to quickly grab the bits we need to get up and running. Spring Boot starters have become so popular that many other third-party library developers are crafting their own.

In addition to starters, we have the following three extra libraries:

  • Project Lombok (https://projectlombok.org) makes it dead simple to define POJOs without getting bogged down in getters, setters, and other details.
  • Flapdoodle is an embedded MongoDB database that allows us to write tests, tinker with a solution, and get things moving before getting involved with an external database.
At the time of writing, Flapdoodle isn't listed on the website. We must add it manually, as shown previously.
  • spring-boot-starter-test pulls in Spring Boot Test, JSONPath, JUnit, AssertJ, Mockito, Hamcrest, JSONassert, and Spring Test, all within test scope.

The value of this last starter, spring-boot-starter-test, cannot be overstated. With a single line, the most powerful test utilities are at our fingertips, allowing us to write unit tests, slice tests, and full-blown our-app-inside-embedded-Netty tests. It's why this starter is included in all projects without checking a box on the Spring Initializr site.

Now, to get things off the ground, we need to shift focus to the tiny bit of code written for us by the Spring Initializr.

You have been reading a chapter from
Learning Spring Boot 2.0 - Second Edition
Published in: Nov 2017
Publisher: Packt
ISBN-13: 9781786463784
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