Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

Reconfiguring the database configuration in MongoDB

First, we will begin to convert the current JBCP calendar project. Let's begin by reconfiguring the database to use the Flapdoodle embedded MongoDB database. Previously, when we updated the dependencies for this project, we added a Flapdoodle dependency that gave the project an embedded MongoDB database which we could automatically use instead of installing a full version of MongoDB installation. To stay consistent with the JBCP application, we need to change the name of our database. With Spring Data, we can change the MongoDB configuration using the YAML configuration, as follows:

    //src/main/resources/application.yml

spring
# MongoDB
data:
mongodb:
host: localhost
database: dataSource

The most important configuration for our current requirements is changing the database name to dataSource, which is the same name we have been using throughout this book.