这里讲解的是在SpringBoot项目中关于RedisTemplate的测试,直接上步骤
一、引入依赖
<!-- testcontainer 包-->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.12.0</version>
</dependency>
<!-- redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
二、配置RedisTemplate
我这里配置的比较简单,大家根据自己的需要进行处理
package com.firewolf.utils.testcontainer.redis;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.re