{"id":13480723,"url":"https://github.com/spring-projects/spring-data-mongodb","last_synced_at":"2026-02-13T15:20:02.347Z","repository":{"id":1741019,"uuid":"2566570","full_name":"spring-projects/spring-data-mongodb","owner":"spring-projects","description":"Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.","archived":false,"fork":false,"pushed_at":"2025-05-06T13:34:02.000Z","size":36996,"stargazers_count":1642,"open_issues_count":289,"forks_count":1100,"subscribers_count":167,"default_branch":"main","last_synced_at":"2025-05-06T15:03:45.748Z","etag":null,"topics":["ddd","framework","java","mongodb","spring","spring-data"],"latest_commit_sha":null,"homepage":"https://spring.io/projects/spring-data-mongodb/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spring-projects.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.adoc","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-10-13T01:06:55.000Z","updated_at":"2025-05-06T10:11:32.000Z","dependencies_parsed_at":"2023-12-21T16:09:58.440Z","dependency_job_id":"3b67512f-31ea-4335-97b6-838b23b7fd79","html_url":"https://github.com/spring-projects/spring-data-mongodb","commit_stats":{"total_commits":3892,"total_committers":219,"mean_commits":"17.771689497716896","dds":0.8381294964028777,"last_synced_commit":"315b91048e6cd7d6e8776fdab6e1802d7ec53a13"},"previous_names":["springsource/spring-data-mongodb"],"tags_count":351,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-data-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-data-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-data-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-data-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spring-projects","download_url":"https://codeload.github.com/spring-projects/spring-data-mongodb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969228,"owners_count":21992262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd","framework","java","mongodb","spring","spring-data"],"created_at":"2024-07-31T17:00:44.171Z","updated_at":"2025-12-16T13:06:07.962Z","avatar_url":"https://github.com/spring-projects.png","language":"Java","readme":"= Spring Data MongoDB image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-mongodb%2Fmain\u0026subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-mongodb/] image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle\u0026labelColor=02303A[\"Revved up by Develocity\", link=\"https://ge.spring.io/scans?search.rootProjectNames=Spring Data MongoDB\"]\n\nThe primary goal of the https://spring.io/projects/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.\n\nThe Spring Data project aims to provide a familiar and consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities.\nThe Spring Data MongoDB project provides integration with the MongoDB document database.\nKey functional areas of Spring Data MongoDB are a POJO centric model for interacting with a MongoDB `+Document+` and easily writing a repository style data access layer.\n\n[[code-of-conduct]]\n== Code of Conduct\n\nThis project is governed by the https://github.com/spring-projects/.github/blob/main/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to spring-code-of-conduct@spring.io.\n\n[[getting-started]]\n== Getting Started\n\nHere is a quick teaser of an application using Spring Data Repositories in Java:\n\n[source,java]\n----\npublic interface PersonRepository extends CrudRepository\u003cPerson, Long\u003e {\n\n  List\u003cPerson\u003e findByLastname(String lastname);\n\n  List\u003cPerson\u003e findByFirstnameLike(String firstname);\n}\n\n@Service\npublic class MyService {\n\n  private final PersonRepository repository;\n\n  public MyService(PersonRepository repository) {\n    this.repository = repository;\n  }\n\n  public void doWork() {\n\n    repository.deleteAll();\n\n    Person person = new Person();\n    person.setFirstname(\"Oliver\");\n    person.setLastname(\"Drotbohm\");\n    repository.save(person);\n\n    List\u003cPerson\u003e lastNameResults = repository.findByLastname(\"Drotbohm\");\n    List\u003cPerson\u003e firstNameResults = repository.findByFirstnameLike(\"Oli*\");\n }\n}\n\n@Configuration\n@EnableMongoRepositories\nclass ApplicationConfig extends AbstractMongoClientConfiguration {\n\n  @Override\n  protected String getDatabaseName() {\n    return \"springdata\";\n  }\n}\n----\n\n[[maven-configuration]]\n=== Maven configuration\n\nAdd the Maven dependency:\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.springframework.data\u003c/groupId\u003e\n  \u003cartifactId\u003espring-data-mongodb\u003c/artifactId\u003e\n  \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nIf you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository\nand declare the appropriate dependency version.\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.springframework.data\u003c/groupId\u003e\n  \u003cartifactId\u003espring-data-mongodb\u003c/artifactId\u003e\n  \u003cversion\u003e${version}-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003crepository\u003e\n  \u003cid\u003espring-snapshot\u003c/id\u003e\n  \u003cname\u003eSpring Snapshot Repository\u003c/name\u003e\n  \u003curl\u003ehttps://repo.spring.io/snapshot\u003c/url\u003e\n\u003c/repository\u003e\n----\n\n[[upgrading]]\n== Upgrading\n\nInstructions for how to upgrade from earlier versions of Spring Data are provided on the project https://github.com/spring-projects/spring-data-commons/wiki[wiki].\nFollow the links in the https://github.com/spring-projects/spring-data-commons/wiki#release-notes[release notes section] to find the version that you want to upgrade to.\n\n[[getting-help]]\n== Getting Help\n\nHaving trouble with Spring Data? We’d love to help!\n\n* Check the\nhttps://docs.spring.io/spring-data/mongodb/reference/[reference documentation], and https://docs.spring.io/spring-data/mongodb/docs/current/api/[Javadocs]\n* Learn the Spring basics – Spring Data builds on Spring Framework, check the https://spring.io[spring.io] web-site for a wealth of reference documentation.\nIf you are just starting out with Spring, try one of the https://spring.io/guides[guides].\n* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-mongodb`].\n* Report bugs with Spring Data MongoDB at https://github.com/spring-projects/spring-data-mongodb/issues[github.com/spring-projects/spring-data-mongodb/issues].\n\n[[reporting-issues]]\n== Reporting Issues\n\nSpring Data uses Github as issue tracking system to record bugs and feature requests.\nIf you want to raise an issue, please follow the recommendations below:\n\n* Before you log a bug, please search the https://github.com/spring-projects/spring-data-mongodb/issues[issue tracker] to see if someone has already reported the problem.\n* If the issue does not already exist, https://github.com/spring-projects/spring-data-mongodb/issues/new[create a new issue].\n* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.\n* Ideally provide a complete https://stackoverflow.com/help/minimal-reproducible-example[minimal sample] (something that we can unzip or git clone, build, and deploy) that reproduces the problem.\n* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.\n\n[[guides]]\n== Guides\n\nThe https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step:\n\n* https://spring.io/guides/gs/accessing-data-mongodb/[Accessing Data with MongoDB] is a very basic guide that shows you how to create a simple application and how to access data using repositories.\n* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories.\n\n[[examples]]\n== Examples\n\n* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.\n\n[[building-from-source]]\n== Building from Source\n\nYou do not need to build from source to use Spring Data. Binaries are available in https://central.sonatype.com[Maven Central] or in case of snapshots from  https://repo.spring.io[repo.spring.io]\nand accessible from Maven using the Maven configuration noted \u003c\u003cmaven-configuration,above\u003e\u003e.\n\nNOTE: Configuration for Gradle is similar to Maven.\n\nThe best way to get started is by creating a Spring Boot project using MongoDB on https://start.spring.io[start.spring.io].\nFollow this https://start.spring.io/#type=maven-project\u0026language=java\u0026platformVersion=3.0.0\u0026packaging=jar\u0026jvmVersion=17\u0026groupId=com.example\u0026artifactId=demo\u0026name=demo\u0026description=Demo%20project%20for%20Spring%20Boot\u0026packageName=com.example.demo\u0026dependencies=data-mongodb[link]\nto build an imperative application and this https://start.spring.io/#type=maven-project\u0026language=java\u0026platformVersion=3.0.0\u0026packaging=jar\u0026jvmVersion=17\u0026groupId=com.example\u0026artifactId=demo\u0026name=demo\u0026description=Demo%20project%20for%20Spring%20Boot\u0026packageName=com.example.demo\u0026dependencies=data-mongodb-reactive[link]\nto build a reactive one.\n\nHowever, if you want to try out the latest and greatest, Spring Data MongoDB can be easily built with the https://github.com/takari/maven-wrapper[Maven wrapper]\nand minimally, JDK 17 (https://www.oracle.com/java/technologies/downloads/[JDK downloads]).\n\nIn order to build Spring Data MongoDB, you will need to https://www.mongodb.com/try/download/community[download]\nand https://docs.mongodb.com/manual/installation/[install a MongoDB distribution] and https://www.docker.com/products/docker-desktop/[Docker].\n\nOnce you have installed MongoDB, you need to start a MongoDB server. It is convenient to set an environment variable to\nyour MongoDB installation directory (e.g. `MONGODB_HOME`).\n\nTo run the full test suite, a https://docs.mongodb.com/manual/tutorial/deploy-replica-set/[MongoDB Replica Set]\nis required.\n\nTo run the MongoDB server enter the following command from a command-line:\n\n[source,bash]\n----\n$ $MONGODB_HOME/bin/mongod --dbpath $MONGODB_HOME/runtime/data --ipv6 --port 27017 --replSet rs0\n...\n\"msg\":\"Successfully connected to host\"\n----\n\nOnce the MongoDB server starts up, you should see the message (`msg`), \"_Successfully connected to host_\".\n\nNotice the `--dbpath` option to the `mongod` command. You can set this to anything you like, but in this case, we set\nthe absolute path to a sub-directory (`runtime/data/`) under the MongoDB installation directory (in `$MONGODB_HOME`).\n\nYou need to initialize the MongoDB replica set only once on the first time the MongoDB server is started.\nTo initialize the replica set, start a mongo client:\n\n[source,bash]\n----\n$ $MONGODB_HOME/bin/mongo\nMongoDB server version: 8.0.0\n...\n----\n\nThen enter the following command:\n\n[source,bash]\n----\nmongo\u003e rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: '127.0.0.1:27017' } ] })\n----\n\nFinally, on UNIX-based system (for example, Linux or Mac OS X) you may need to adjust the `ulimit`.\nIn case you need to, you can adjust the `ulimit` with the following command (32768 is just a recommendation):\n\n[source,bash]\n----\n$ ulimit -n 32768\n----\n\nYou can use `ulimit -a` again to verify the `ulimit` for \"_open files_\" was set appropriately.\n\nNow you are ready to build Spring Data MongoDB. Simply enter the following `mvnw` (Maven Wrapper) command:\n\n[source,bash]\n----\n $ ./mvnw clean install\n----\n\nIf you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.8.0 or above].\n\nAlso see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] and add a _Signed-off-by_ trailer to your commits, if you wish to submit a pull request.\n\n=== Building reference documentation\n\nBuilding the documentation builds also the project without running tests.\n\n[source,bash]\n----\n $ ./mvnw clean install -Pantora\n----\n\nThe generated documentation is available from `target/antora/site/index.html`.\n\n[[license]]\n== License\n\nSpring Data MongoDB is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].\n","funding_links":[],"categories":["Libraries","II. Databases, search engines, big data and machine learning"],"sub_categories":["Java","4. Client and drivers for databases"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-data-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-projects%2Fspring-data-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-data-mongodb/lists"}