Hi
I tried to start Spring Boot 2.0 application with Spring Data Redis 2.0 support but startup failed with error:
Caused by: java.lang.IllegalArgumentException: No session repository could be auto-configured, check your configuration (session store type is 'redis')
at org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$SessionRepositoryValidator.checkSessionRepository(SessionAutoConfiguration.java:104) ~[spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
Here is my application.properties:
spring.session.store-type=redis
And my configuration:
@Configuration
public class SessionConfig {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory();
}
}
I removed @EnableSpringHttpSession(former @EnableRedisHttpSession) annotation from this class because it gave another error if present:
Parameter 0 of method springSessionRepositoryFilter in org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration required a bean of type 'org.springframework.session.SessionRepository' that could not be found.
- Bean method 'sessionRepository' not loaded because Session Condition found spring.session.store-type property REDIS
Please, advise.
Hi @sergey-morenets, this looks more of a Boot auto-configuration issue rather than problem with Spring Session.
Can you provide a minimal sample application that reproduces the problem?
Also could you clarify this statement (in particular the _former_ part):
I removed @enablespringhttpsession(former @enableredishttpsession) annotation from this class because it gave another error if present
Note that with Spring Boot you generally don't want @Enable*HttpSession annotation on your config as this will disable Boot's auto-config.
Hi @vpavic
Yes, I will prepare today this minimal sample application. I have standard Spring Boot application with Spring Data Redis 1.3.1 that I try to upgrade to 2.0
Hi @vpavic
I attached minimal sample application where I could reproduce this issue. Please investigate.
rest-samples.zip
Thank you for the sample @sergey-morenets!
The problem was that spring-session-data-redis dependency was declared with <type>pom</type> in your pom.xml. I've removed that line and the sample now starts correctly.
That approach was working in with pre-2.0 releases of Spring Session since spring-session-data-redis module was just a starter/dependency aggregator while spring-session artifact contained all the code. However in 2.0 we have split the modules so now spring-session-data-redis contains all the Redis related code. See #768 and this blog post for more background on the change.
As a sidenote, you don't have to configure LettuceConnectionFactory manually - Spring Boot has first-class support for Lettuce since 2.0.0.M1 - see spring-projects/spring-boot#5311.
Thank you, @vpavic
Now it works perfectly.
I figured out, i imported both spring-session and spring-session-data-redis and my spring boot version was 2.1.0. After removing the spring-session dependency, it worked.
Hello @abuabdul I have the same issue but I tried your solution nothing happens. Do you have a suggestion ?
Most helpful comment
I figured out, i imported both spring-session and spring-session-data-redis and my spring boot version was 2.1.0. After removing the spring-session dependency, it worked.