The Spring Data MongoDB project applies core Spring concepts to the development of solutions that use the MongoDB document style data store. We provide a “template” as a high-level abstraction for storing and querying documents. You may notice similarities to the JDBC support provided by the Spring Framework.
This document is the reference guide for Spring Data - MongoDB Support. It explains MongoDB module concepts and semantics and syntax for various store namespaces.
This section provides some basic introduction to Spring and Document databases. The rest of the document refers only to Spring Data MongoDB features and assumes the user is familiar with MongoDB and Spring concepts.
Spring Data uses Spring framework’s core functionality, including:
While you need not know the Spring APIs, understanding the concepts behind them is important. At a minimum, the idea behind Inversion of Control (IoC) should be familiar, and you should be familiar with whatever IoC container you choose to use.
The core functionality of the MongoDB support can be used directly, with no need to invoke the IoC services of the Spring Container. This is much like JdbcTemplate
, which can be used "'standalone'" without any other services of the Spring container. To leverage all the features of Spring Data MongoDB, such as the repository support, you need to configure some parts of the library to use Spring.
To learn more about Spring, you can refer to the comprehensive documentation that explains the Spring Framework in detail. There are a lot of articles, blog entries, and books on the subject. See the Spring framework home page for more information.
NoSQL stores have taken the storage world by storm. It is a vast domain with a plethora of solutions, terms, and patterns (to make things worse, even the term itself has multiple meanings). While some of the principles are common, you must be familiar with MongoDB to some degree. The best way to get acquainted is to read the documentation and follow the examples. It usually does not take more then 5-10 minutes to go through them and, especially if you are coming from an RDMBS-only background, these exercises can be an eye opener.
The starting point for learning about MongoDB is www.mongodb.org. Here is a list of other useful resources:
-
The manual introduces MongoDB and contains links to getting started guides, reference documentation, and tutorials.
-
The online shell provides a convenient way to interact with a MongoDB instance in combination with the online tutorial.
-
MongoDB Java Language Center.
-
Several books you can purchase.
-
Karl Seguin’s online book: The Little MongoDB Book.
The Spring Data MongoDB 3.x binaries require JDK level 8.0 and above and Spring Framework {springVersion} and above.
In terms of document stores, you need at least version 3.6 of MongoDB, though we recommend a more recent version.
The following compatibility matrix summarizes Spring Data versions to MongoDB driver/database versions. Database versions show the highest supported server version that pass the Spring Data test suite. You can use newer server versions unless your application uses functionality that is affected by changes in the MongoDB server.
Spring Data Release Train | Spring Data MongoDB | Driver Version | Server Version |
---|---|---|---|
2021.0 |
|
|
|
2020.0 |
|
|
|
Neumann |
|
|
|
Moore |
|
|
|
Lovelace |
|
|
|
-
Fields list must not contain text search score property when no
$text
criteria present. See also$text
operator -
Sort must not be an empty document when running map reduce.
-
Removal of
geoNear
command. See also Removal ofgeoNear
-
Removal of
eval
command. See also Removal ofeval
Learning a new framework is not always straightforward. In this section, we try to provide what we think is an easy-to-follow guide for starting with the Spring Data MongoDB module. However, if you encounter issues or you need advice, feel free to use one of the following links:
- Community Forum
-
Spring Data on Stack Overflow is a tag for all Spring Data (not just Document) users to share information and help each other. Note that registration is needed only for posting.
- Professional Support
-
Professional, from-the-source support, with guaranteed response time, is available from Pivotal Software, Inc., the company behind Spring Data and Spring.
For information on the Spring Data Mongo source code repository, nightly builds, and snapshot artifacts, see the Spring Data Mongo homepage. You can help make Spring Data best serve the needs of the Spring community by interacting with developers through the Community on Stack Overflow. To follow developer activity, look for the mailing list information on the Spring Data Mongo homepage. If you encounter a bug or want to suggest an improvement, please create a ticket on the Spring Data issue tracker. To stay up to date with the latest news and announcements in the Spring eco system, subscribe to the Spring Community Portal. You can also follow the Spring blog or the project team on Twitter (SpringData).