You do not need to build from source to use Spring Data. Binaries are available in Maven Central or in case of snapshots from repo.spring.io
and accessible from Maven using the Maven configuration noted above.
|
Note
|
Configuration for Gradle is similar to Maven.
|
The best way to get started is by creating a Spring Boot project using MongoDB on start.spring.io.
Follow this link
to build an imperative application and this link
to build a reactive one.
However, if you want to try out the latest and greatest, Spring Data MongoDB can be easily built with the Maven wrapper
and minimally, JDK 17 (JDK downloads).
Once you have installed MongoDB, you need to start a MongoDB server. It is convenient to set an environment variable to
your MongoDB installation directory (e.g. MONGODB_HOME).
To run the MongoDB server enter the following command from a command-line:
$ $MONGODB_HOME/bin/mongod --dbpath $MONGODB_HOME/runtime/data --ipv6 --port 27017 --replSet rs0
...
"msg":"Successfully connected to host"
Once the MongoDB server starts up, you should see the message (msg), "Successfully connected to host".
Notice the --dbpath option to the mongod command. You can set this to anything you like, but in this case, we set
the absolute path to a sub-directory (runtime/data/) under the MongoDB installation directory (in $MONGODB_HOME).
You need to initialize the MongoDB replica set only once on the first time the MongoDB server is started.
To initialize the replica set, start a mongo client:
$ $MONGODB_HOME/bin/mongo
MongoDB server version: 8.0.0
...
Then enter the following command:
mongo> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: '127.0.0.1:27017' } ] })
Finally, on UNIX-based system (for example, Linux or Mac OS X) you may need to adjust the ulimit.
In case you need to, you can adjust the ulimit with the following command (32768 is just a recommendation):
You can use ulimit -a again to verify the ulimit for "open files" was set appropriately.
Now you are ready to build Spring Data MongoDB. Simply enter the following mvnw (Maven Wrapper) command:
Also see CONTRIBUTING.adoc and add a Signed-off-by trailer to your commits, if you wish to submit a pull request.
Building reference documentation
Building the documentation builds also the project without running tests.
$ ./mvnw clean install -Pantora
The generated documentation is available from target/antora/site/index.html.