Change preference of session store implementations
The order has been determined based on usage statistics. Closes gh-27756
This commit is contained in:
parent
6f65777035
commit
4057dd198b
|
|
@ -116,8 +116,8 @@ public class SessionAutoConfiguration {
|
|||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnMissingBean(SessionRepository.class)
|
||||
@Import({ RedisSessionConfiguration.class, MongoSessionConfiguration.class, HazelcastSessionConfiguration.class,
|
||||
JdbcSessionConfiguration.class })
|
||||
@Import({ RedisSessionConfiguration.class, JdbcSessionConfiguration.class, HazelcastSessionConfiguration.class,
|
||||
MongoSessionConfiguration.class })
|
||||
static class ServletSessionRepositoryConfiguration {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur
|
|||
}
|
||||
|
||||
@Test
|
||||
void hazelcastTakesPrecedenceOverJdbc() {
|
||||
void hazelcastTakesPrecedenceOverMongo() {
|
||||
this.contextRunner.withClassLoader(
|
||||
new FilteredClassLoader(RedisIndexedSessionRepository.class, MongoIndexedSessionRepository.class))
|
||||
new FilteredClassLoader(RedisIndexedSessionRepository.class, JdbcIndexedSessionRepository.class))
|
||||
.run(this::validateDefaultConfig);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
|
|||
this.contextRunner.run(this::validateDefaultConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
void jdbcTakesPrecedenceOverMongoAndHazelcast() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(RedisIndexedSessionRepository.class))
|
||||
.run(this::validateDefaultConfig);
|
||||
}
|
||||
|
||||
private void validateDefaultConfig(AssertableWebApplicationContext context) {
|
||||
JdbcIndexedSessionRepository repository = validateSessionRepository(context,
|
||||
JdbcIndexedSessionRepository.class);
|
||||
|
|
|
|||
|
|
@ -63,12 +63,6 @@ class SessionAutoConfigurationMongoTests extends AbstractSessionAutoConfiguratio
|
|||
this.contextRunner.run(validateSpringSessionUsesMongo("sessions"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mongoTakesPrecedenceOverJdbcAndHazelcast() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(RedisIndexedSessionRepository.class))
|
||||
.run(validateSpringSessionUsesMongo("sessions"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultConfigWithCustomTimeout() {
|
||||
this.contextRunner.withPropertyValues("spring.session.timeout=1m")
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ Spring Boot provides {spring-session}[Spring Session] auto-configuration for a w
|
|||
When building a servlet web application, the following stores can be auto-configured:
|
||||
|
||||
* Redis
|
||||
* MongoDB
|
||||
* Hazelcast
|
||||
* JDBC
|
||||
* Hazelcast
|
||||
* MongoDB
|
||||
|
||||
Additionally, {spring-boot-for-apache-geode}[Spring Boot for Apache Geode] provides {spring-boot-for-apache-geode-docs}#geode-session[auto-configuration for using Apache Geode as a session store].
|
||||
|
||||
|
|
@ -16,10 +16,10 @@ If a single Spring Session module is present on the classpath, Spring Boot uses
|
|||
If you have more than one implementation, Spring Boot uses the following order for choosing a specific implementation:
|
||||
|
||||
. Redis
|
||||
. MongoDB
|
||||
. Hazelcast
|
||||
. JDBC
|
||||
. If none of Redis, MongoDB, Hazelcast and JDBC are available, we do not configure a `SessionRepository`.
|
||||
. Hazelcast
|
||||
. MongoDB
|
||||
. If none of Redis, JDBC, Hazelcast and MongoDB are available, we do not configure a `SessionRepository`.
|
||||
|
||||
|
||||
When building a reactive web application, the following stores can be auto-configured:
|
||||
|
|
|
|||
Loading…
Reference in New Issue