Make spring.session.store-type mandatory

Previously, Spring Session would be auto-configured by the mere presence
of Spring Session in the classpath. This was fragile as determining a
store type according to the environment could easily change when the
classpath of the project changes.

This commit makes the store-type property mandatory. If it is not set,
Spring Session is no longer auto-configured.

Closes gh-5838
This commit is contained in:
Stephane Nicoll
2016-05-09 08:07:25 +02:00
parent d80717349a
commit b7e7bcf717
6 changed files with 34 additions and 20 deletions

View File

@@ -362,7 +362,7 @@ content into your application; rather pick only the properties that you need.
spring.session.mongo.collection-name=sessions # Collection name used to store sessions.
spring.session.redis.flush-mode= # Flush mode for the Redis sessions.
spring.session.redis.namespace= # Namespace for keys used to store sessions.
spring.session.store-type= # Session store type, auto-detected according to the environment by default.
spring.session.store-type= # Session store type.
# SPRING SOCIAL ({sc-spring-boot-autoconfigure}/social/SocialWebAutoConfiguration.{sc-ext}[SocialWebAutoConfiguration])
spring.social.auto-connection-views=false # Enable the connection status view for supported providers.

View File

@@ -4392,9 +4392,7 @@ class for more details.
[[boot-features-session]]
== Spring Session
Spring Boot provides Spring Session auto-configuration for a wide range of stores. If
Spring Session is available and you haven't defined a bean of type `SessionRepository`,
Spring Boot tries to detect the following session stores (in this order):
Spring Boot provides Spring Session auto-configuration for a wide range of stores:
* JDBC
* MongoDB
@@ -4402,9 +4400,18 @@ Spring Boot tries to detect the following session stores (in this order):
* Hazelcast
* HashMap
It is also possible to _force_ the store to use via the `spring.session.store-type`
property. Each store have specific additional settings. For instance it is possible
to customize the name of the table for the jdbc store:
If Spring Session is available, you only need to chose the
{sc-spring-boot-autoconfigure}/session/StoreType.{sc-ext}[`StoreType`] that you wish to
use to store the sessions. For instance to use Redis as backend store, you'd configure
your application as follows:
[source,properties,indent=0]
----
spring.session.store-type=redis
----
Each store has specific additional settings. For instance it is possible to customize
the name of the table for the jdbc store:
[source,properties,indent=0]
----