Merge branch '1.5.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.session;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -45,8 +40,6 @@ import org.springframework.session.data.redis.config.annotation.web.http.RedisHt
|
||||
@Conditional(SessionCondition.class)
|
||||
class RedisSessionConfiguration {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(RedisSessionConfiguration.class);
|
||||
|
||||
@Configuration
|
||||
public static class SpringBootRedisHttpSessionConfiguration
|
||||
extends RedisHttpSessionConfiguration {
|
||||
@@ -65,14 +58,6 @@ class RedisSessionConfiguration {
|
||||
setRedisFlushMode(redis.getFlushMode());
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void validate() {
|
||||
if (this.sessionProperties.getStoreType() == null) {
|
||||
logger.warn("Spring Session store type is mandatory: set "
|
||||
+ "'spring.session.store-type=redis' in your configuration");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,19 +23,15 @@ import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* General condition used with all session configuration classes.
|
||||
*
|
||||
* @author Tommy Ludwig
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class SessionCondition extends SpringBootCondition {
|
||||
|
||||
private static final boolean redisPresent = ClassUtils.isPresent(
|
||||
"org.springframework.data.redis.core.RedisTemplate",
|
||||
SessionCondition.class.getClassLoader());
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
@@ -46,10 +42,6 @@ class SessionCondition extends SpringBootCondition {
|
||||
StoreType sessionStoreType = SessionStoreMappings
|
||||
.getType(((AnnotationMetadata) metadata).getClassName());
|
||||
if (!resolver.containsProperty("store-type")) {
|
||||
if (sessionStoreType == StoreType.REDIS && redisPresent) {
|
||||
return ConditionOutcome.match(
|
||||
message.foundExactly("default store type of redis (deprecated)"));
|
||||
}
|
||||
return ConditionOutcome.noMatch(
|
||||
message.didNotFind("spring.session.store-type property").atAll());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,13 +24,10 @@ import org.junit.Test;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.redis.RedisTestServer;
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.session.data.redis.RedisFlushMode;
|
||||
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
/**
|
||||
* Redis specific tests for {@link SessionAutoConfiguration}.
|
||||
@@ -40,27 +37,14 @@ import static org.hamcrest.Matchers.containsString;
|
||||
public class SessionAutoConfigurationRedisTests
|
||||
extends AbstractSessionAutoConfigurationTests {
|
||||
|
||||
@Rule
|
||||
public OutputCapture output = new OutputCapture();
|
||||
|
||||
@Rule
|
||||
public final RedisTestServer redis = new RedisTestServer();
|
||||
|
||||
@Test
|
||||
public void redisSessionStoreIsTheDefault() {
|
||||
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class));
|
||||
validateSpringSessionUsesRedis();
|
||||
this.output.expect(containsString(
|
||||
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void redisSessionStore() {
|
||||
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class),
|
||||
"spring.session.store-type=redis");
|
||||
validateSpringSessionUsesRedis();
|
||||
this.output.expect(not(containsString(
|
||||
"Spring Session store type is mandatory: set 'spring.session.store-type=redis' in your configuration")));
|
||||
}
|
||||
|
||||
private void validateSpringSessionUsesRedis() {
|
||||
|
||||
@@ -4959,7 +4959,7 @@ Spring Boot provides Spring Session auto-configuration for a wide range of store
|
||||
* Hazelcast
|
||||
* HashMap
|
||||
|
||||
If Spring Session is available, you only need to choose the
|
||||
If Spring Session is available, you must choose the
|
||||
{sc-spring-boot-autoconfigure}/session/StoreType.{sc-ext}[`StoreType`] that you wish to
|
||||
use to store the sessions. For instance to use JDBC as backend store, you'd configure
|
||||
your application as follows:
|
||||
@@ -4969,9 +4969,6 @@ your application as follows:
|
||||
spring.session.store-type=jdbc
|
||||
----
|
||||
|
||||
NOTE: For backward compatibility if Redis is available Spring Session will be automatically
|
||||
configured to use Redis.
|
||||
|
||||
TIP: You can disable Spring Session by setting the `store-type` to `none`.
|
||||
|
||||
Each store has specific additional settings. For instance it is possible to customize
|
||||
|
||||
Reference in New Issue
Block a user