I am building an app with spring-boot
. In order to avoid sticky-session related problems, I put in place a redis session store by adding those lines in pom.xml
:
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
and those lines in application.properties :
spring.redis.host=localhost
spring.redis.password=secret
spring.redis.port=6379
It worked like a charm. I was surprised that it worked even if I did not use the annotation @EnableRedisHttpSession
. At the beginning, I found it nice.
Problem : I have a Spring configuration for the real application and also a Spring configuration dedicated to unit tests. The Redis connection is useless in the unit test environment and make the test fail if I do not install a Redis server in the test environment.
I could eventually install a Mock Redis as a maven dependency but it would be cleaner if I found a way to disable this useless connection.
Any idea?