Skip to content

vpavic/samples-spring-session

Repository files navigation

Samples: Spring Session

Build

This repository contains sample applications that showcase basic Spring Session functionalities across different web stacks and data stores.

The name of each sample application contains the web stack integration it’s based on, and the data store is uses to store sessions. Below is the list of all the provided sample applications:

  • HttpSession

    • Redis

    • JDBC

    • Hazelcast

    • MongoDB

    • Infinispan (3rd party integration)

  • WebSession

    • Redis

    • MongoDB

Getting Started

Requirements

Java 17 is required to run the samples.

The project is built using Gradle and uses Gradle Wrapper to take care of downloading the appropriate Gradle version.

Running the Samples

Each sample is a Spring Boot based application that can be run using:

  • using the bootRun task of the appropriate sample application

  • from your IDE by running sample application’s main class

By default, all samples start web server on port 8080.

HttpSession Redis

$ ./gradlew :sample-httpsession-redis:bootRun

By default, this sample will attempt to connect to Redis running locally at port 6379.

HttpSession JDBC

$ ./gradlew :sample-httpsession-jdbc:bootRun

By default, this sample will attempt to connect to PostgreSQL running locally at port 5432 using database spring_session, username spring_session and password spring_session.

The project contains the JDBC driver for the following RDMBSs:

  • DB2

  • MariaDB

  • MySQL

  • Oracle

  • PostgreSQL

  • SQL Server

HttpSession Hazelcast

$ ./gradlew :sample-httpsession-hazelcast:bootRun

By default, this sample will start an embedded Hazelcast instance.

HttpSession Infinispan

$ ./gradlew :sample-httpsession-infinispan:bootRun

By default, this sample will start an embedded Infinispan instance.

HttpSession MongoDB

$ ./gradlew :sample-httpsession-mongodb:bootRun

By default, this sample will attempt to connect to MongoDB running locally at port 27017.

WebSession Redis

$ ./gradlew :sample-websession-redis:bootRun

By default, this sample will attempt to connect to Redis running locally at port 6379.

WebSession MongoDB

$ ./gradlew :sample-websession-mongodb:bootRun

By default, this sample will attempt to connect to MongoDB running locally at port 27017.

Building from Source

To build the project from source, you will need to have Docker installed.

To project can be built the build task:

$ ./gradlew build