Allow DevTools to find and configure Spring Session 1.1's RedisTemplate
Previously, when Spring Session 1.1.0.M1 and DevTools were declared as dependencies the application failed to start, because sessionRedisTemplate could not be resolved. This commit relaxes the dependency for sessionRedisTemplate in restartCompatibleRedisSerializerConfigurer from RedisTemplate<String, ExpiringSession> to RedisTemplate<?, ?> and uses the bean name in a @Qualifer to ensure that the right RedisTemplate bean gets injected. Fixes gh-4895 Closes gh-4896
This commit is contained in:
committed by
Andy Wilkinson
parent
da4504118e
commit
3e291ff04f
@@ -21,6 +21,7 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -42,7 +43,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ public class LocalDevToolsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestartCompatibleRedisSerializerConfigurer restartCompatibleRedisSerializerConfigurer(
|
||||
RedisTemplate<String, ExpiringSession> sessionRedisTemplate) {
|
||||
@Qualifier("sessionRedisTemplate") RedisTemplate<?, ?> sessionRedisTemplate) {
|
||||
return new RestartCompatibleRedisSerializerConfigurer(
|
||||
sessionRedisTemplate);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.core.serializer.support.SerializingConverter;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationException;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -42,12 +41,11 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
class RestartCompatibleRedisSerializerConfigurer implements BeanClassLoaderAware {
|
||||
|
||||
private final RedisTemplate<String, ExpiringSession> redisTemplate;
|
||||
private final RedisTemplate<?, ?> redisTemplate;
|
||||
|
||||
private volatile ClassLoader classLoader;
|
||||
|
||||
RestartCompatibleRedisSerializerConfigurer(
|
||||
RedisTemplate<String, ExpiringSession> redisTemplate) {
|
||||
RestartCompatibleRedisSerializerConfigurer(RedisTemplate<?, ?> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user