...

/

Defining Our E-commerce Application’s Domain

Defining Our E-commerce Application’s Domain

Learn how to add the required database dependencies and define the required domains for our e-commerce application.

In this lesson, now that we’re embracing a real database, we can actually start modeling our e-commerce site. Let’s start with a new project created using Spring Initializr.

Adding database dependencies

First, we’ll add some new dependencies to our pom.xml build file:

<dependencies>
<!-- tag::mongodb[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
</dependency>
<!-- end::mongodb[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
The MongoDB dependencies added to our pom.xml build file

Line 5 has the first dependency, spring-boot-starter-data-mongodb-reactive, which is one of Spring Boot’s startersSpringBootStarter, as shown in pom.xml.

There are many reactive datastore modules in Spring Boot.

Reactive datastore modules

Module

Description

spring-boot-starter

Core Spring Boot module that glues things together

spring-data-mongodb

Spring Data MongoDB itself, but with the blocking MongoDB drivers excluded

mongodb-driver-reactivestreams

MongoDB’s official Reactive Streams driver

That starter introduces Spring Data MongoDB. Specifically, it introduces the reactive version of that library. A classic ...