1、在pom.xml引入父依赖spring-boot-starter-parent,其中2.7.18是最后一版支持java8的spring
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.18</version>
		<relativePath/>
	</parent> 
然后引入spring-boot-starter-data-redis,这时不需要写<version>标签,版本信息从父依赖获取
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
		</dependency> 
注意:网上的视频教程大多为了照顾初学者,只教spring项目的pom.xml配置,不教springboot的配置,需要引入很多依赖项,且未考虑依赖冲突,实际生产中使用教学中的pom.xml配置不合适。 另外,spring版本和spring data redis版本号基本同步,spring有2.7.18,则spring data redis也有2.7.18,这也是处理依赖兼容性的一种思路。
2、配置yml
spring:
  application:
    name: AnswerRecord
  redis:
    port: 6379 #Redis服务器连接的端口
    host: 127.0.0.1 # Redis服务器的地址
    # database:0 # Redis数据库索引(默认为0
    password: # Redis服务器连接密码(默认为空)
    timeout: 5000ms # 连接超时时间(毫秒)
    jedis:
      pool:
        max-active: 8 # 连接池最大连接数(使用负值表示没有限制)
        max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
        max-idle: 8 # 连接池中的最大空闲连接
        min-idle: 0 # 连接池中的最小空闲连接
 
yml配置参考:
https://blog.csdn.net/Er_fengV/article/details/116210657
https://blog.csdn.net/Er_fengV/article/details/116210657
3、写测试代码
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	@Test
	public void test2(){
		stringRedisTemplate.opsForValue().set("name","jack");
		System.out.println("set字符串完成。");
		Object name = stringRedisTemplate.opsForValue().get("name");
		System.out.println("获取到的name: " + name);
	} 
 
模板用法参考:
https://www.cnblogs.com/uncleyong/p/17196440.html
https://www.cnblogs.com/uncleyong/p/17196440.html
初学练习源码:
https://pan.baidu.com/s/1urnP6fIs-f7huQacvuatJQ?pwd=769z
https://pan.baidu.com/s/1urnP6fIs-f7huQacvuatJQ?pwd=769z



















