You can use an embedded Redis like https://github.com/kstyrc/embedded-redis
- Add the dependency to your pom.xml
-
Adjust the properties for your integration test to point to your embedded redis, for example :
spring: redis: host: localhost port: 6379
-
Instanciate the embedded redis server in a component that is defined in your tests only :
@Component public class EmbededRedis { @Value("${spring.redis.port}") private int redisPort; private RedisServer redisServer; @PostConstruct public void startRedis() throws IOException { redisServer = new RedisServer(redisPort); redisServer.start(); } @PreDestroy public void stopRedis() { redisServer.stop(); } }