MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /

Spring Session MongoDB Integration

Spring Session MongoDB is a library that allows Spring-based applications to store HTTP session data in MongoDB. This integration between Spring Session and MongoDB provides reliable and scalable sessions for applications that run on multiple servers or containers, because any instance can access the same session data. When using MongoDB for session storage, you can maintain sessions after your application restarts and share sessions across a cluster with minimal configuration.

Spring Session 4.0 introduces the first MongoDB-maintained release of the Spring Session MongoDB integration. When working with the integration, you can now receive direct support from the MongoDB engineers who develop the MongoDB Java Driver. This change ensures that Spring Session MongoDB aligns with the latest Java driver releases and API improvements.

You can use the MongoDB-maintained Spring Session integration in your application by creating a new Spring Boot application, or by updating an existing application that uses an earlier version of Spring Session MongoDB.

To learn how to create a Spring Boot application that uses Spring Session MongoDB to manage user session information, follow the Get Started with Spring Session MongoDB tutorial.

If you have an existing application that uses the Spring Session MongoDB integration maintained by Spring, migrate to the MongoDB-maintained integration by performing the following updates:

  • Update your Maven artifact from org.springframework.session:spring-session-data-mongodb to org.mongodb:mongo-spring-session. To learn more about the new artifact, see mongodb-spring-session in Maven Central.

  • Change the API namespace from org.springframework.session.data.mongo to org.mongodb.spring.session. Ensure that your import statements use the new namespace.

  • Because Jackson 2 support is now deprecated, update your application to use JacksonMongoSessionConverter. This is the Jackson 3 session converter.

If you have feedback about Spring Session MongoDB, visit the Frameworks section of the MongoDB Feedback Engine. You can propose improvements, report issues, and provide other types of feedback by using this site.

You can also open a case in Jira, our issue management tool, to identify bugs or propose improvements. The following steps describe how to create a Jira issue:

  1. Visit the MongoDB Jira issue tracker and click the signup link. Create an account, and then log in to Jira.

  2. Navigate to the JAVAF Jira project.

  3. Click Create to create a ticket. Provide as much information as possible about the issue or request in the ticket.

Note

Bug reports in the JAVAF Jira project are publicly viewable.

If you’ve identified a security vulnerability in any official MongoDB product, you can report it according to the instructions found in the Create a Vulnerability Report page.

We are happy to accept contributions to help improve Spring Session MongoDB. We will guide user contributions to ensure they meet the standards of the codebase. Ensure that any pull requests include documentation, tests, and pass the gradle checks.

To contribute to the integration, run the following commands to check out the source repository and work on a branch:

git clone https://github.com/mongodb/mongo-spring-session.git
cd mongo-spring-session
git checkout -b myNewFeature

Then, ensure that the code passes gradle checks by running the following command:

./gradlew clean check

To view compatibility information for the MongoDB-maintained Spring Session module, see the compatibility page.

To learn more about Spring Session MongoDB, see the following resources:

Back

Spring Data MongoDB

On this page