Polish spring session auto-configuration

This commit improves the initial submission by adding more tests and
more configuration options.

Closes gh-5158
This commit is contained in:
Stephane Nicoll
2016-04-18 13:35:39 +02:00
parent 0be00e2a6d
commit bf89c8ee46
19 changed files with 528 additions and 324 deletions

View File

@@ -356,8 +356,13 @@ content into your application; rather pick only the properties that you need.
spring.resources.chain.strategy.fixed.version= # Version string to use for the Version Strategy.
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ # Locations of static resources.
# SPRING SESSION ({sc-spring-boot-autoconfigure}/session/SocialWebAutoConfiguration.{sc-ext}[SessionAutoConfiguration])
spring.session.store.store-type= # Session store type
# SPRING SESSION ({sc-spring-boot-autoconfigure}/session/SessionProperties.{sc-ext}[SessionProperties])
spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions.
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.
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 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,21 +4392,24 @@ class for more details.
[[boot-features-session]]
== Spring Session
Spring Session provides support for managing a user's session information. If you are
writing a web application and Spring Session and one the following providers:
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):
* JDBC
* MongoDB
* Redis
* Hazelcast
* Spring Data Mongo
* Spring Data Redis
* HashMap
on the classpath, Spring Boot will auto-configure Spring Session through its
`@EnableJdbcHttpSession`, `@EnableHazelcastHttpSession`, `@EnableMongoHttpSession`,
`@EnableRedisHttpSession`. Session data will be stored in the provider and the session timeout
can be configured using the `server.session.timeout` property.
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:
It is also possible to _force_ the session provider to use via the `spring.session.store.type`
property.
[source,properties,indent=0]
----
spring.session.jdbc.table-name=SESSIONS
----