close

Spring Session MongoDB

2.7.0

Spring Session MongoDB provides an API and implementations for managing a user’s session information stored in MongoDB by leveraging Spring Data MongoDB.

Features

Spring Session MongoDB provides the following features:

  • API and implementations for managing a user’s session

  • HttpSession - allows replacing the HttpSession in an application container (i.e. Tomcat) neutral way

  • Clustered Sessions - Spring Session makes it trivial to support clustered sessions without being tied to an application container specific solution.

  • Multiple Browser Sessions - Spring Session supports managing multiple users' sessions in a single browser instance (i.e. multiple authenticated accounts similar to Google).

  • RESTful APIs - Spring Session allows providing session ids in headers to work with RESTful APIs WebSocket - provides the ability to keep the HttpSession alive when receiving WebSocket messages

Adding Spring Session for MongoDB to your build

Spring Session MongoDB is part of a Maven BOM (Bill of Materials) used to coordinate versions between the core Spring Session project and this MongoDB extension. Each BOM release is called a release train and has a naming strategy, e.g. Apple-SR8, Bean-SR3, etc.

Using the BOM with Maven

With Maven, you need to import the BOM first:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.session</groupId>
      <artifactId>spring-session-bom</artifactId>
      <version>Bean-SR3</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
  • This example is using Bean-SR3, but you plug in the release train version you need.

  • Notice the use of the <dependencyManagement> section and the import scope.

  • The BOM artifact is org.springframework.session:spring-session-bom, and is outside of Spring Session MongoDB.

Next, add your dependencies to the project without a <version>:

<dependencies>
  <dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-data-mongodb</artifactId>
  </dependency>
</dependencies>

Using the BOM with Gradle

Since Gradle has no first-class support for Maven BOMs, you can use Spring’s Dependency management plugin.

Apply the plugin from Gradle Plugin Portal (update the version if needed):

plugins {
  id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

Then use it to import the BOM:

dependencyManagement {
  imports {
    mavenBom 'org.springframework.session:spring-session-bom:Bean-SR3'
  }
}

Finally, add a dependency to the project without a version:

dependencies {
  compile 'org.springframework.session:spring-session-data-mongodb'
}
Spring Initializr

Quickstart Your Project

Bootstrap your application with Spring Initializr.

Documentation

Each Spring project has its own; it explains in great details how you can use project features and what you can achieve with them.
2.7.0 CURRENT GA Reference Doc. API Doc.
3.0.0-M3 PRE Reference Doc. API Doc.
2.6.3 GA Reference Doc. API Doc.
2.5.0 GA Reference Doc. API Doc.
2.4.4 GA Reference Doc. API Doc.
Branch Initial Release End of Support End Commercial Support *
2.6.x
2021-11-16 2022-11-16 2024-03-16
2.5.x
2021-05-19 2022-05-19 2023-09-19
2.4.x
2020-10-28 2021-10-28 2023-02-28

OSS support

Free security updates and bugfixes with support from the Spring community. See VMware Tanzu OSS support policy.

Commercial support

Business support from Spring experts during the OSS timeline, plus extended support after OSS End-Of-Life.
Publicly available releases for critical bugfixes and security issues when requested by customers.

Future release

Generation not yet released, timeline is subject to changes.

About commercial support (*)

This page shows the current state of project releases and does not define the commercial support policy. Please refer to the official support policy for more information.