Since this book is aimed at the cutting edge of Spring Boot 2.0 and its Reactive Streams support, we have to pick something a little more up to date than JPA. The JPA spec doesn't cover reactive programming. Hence, its APIs are not reactive. However, MongoDB has reactive drivers, and will be perfect.
To get going, we need to install the latest version of MongoDB 3.4 (for reactive support).
If you're using macOS X, installing MongoDB is as simple as this:
$ brew install mongodb ==> Installing mongodb ==> Downloading https://homebrew.bintray.com/bottles/mongodb-
3.4.6.el_capitan.bottle.tar.gz ########################################################## 100.0% ==> Pouring mongodb-3.4.6.el_capitan.bottle.tar.gz ==> Summary /usr/local/Cellar/mongodb/3.4.6: 18 files, 267.5MB
With MongoDB installed, we can launch it as a service, like this:
$ brew services start mongodb ==> Successfully started `mongodb` (label: homebrew.mxcl.mongodb)
Assuming that we have MongoDB installed and running, we can now delve into writing a little code.
To write any MongoDB code, we need to add Spring Data MongoDB to our classpath. We can do so by updating our build file with the following:
compile('org.springframework.boot:spring-boot-starter-
data-mongodb-reactive')
The preceding, new compile-time dependency pulls in the following:
- Spring Data MongoDB
- MongoDB's core components + Reactive Stream drivers
With all these things on the classpath, Spring Boot will get busy configuring things for us. But first, what is the problem we are trying to solve?