引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
@Test
void testHash2() throws JsonProcessingException {
Blog blog = new Blog();
ValueOperations vo = redisTemplate.opsForValue();
vo.set("blog", blog);
System.out.println(vo.get("blog"));
//=====
HashOperations ho = redisTemplate.opsForHash();
ObjectMapper objectMapper = new ObjectMapper();
blog.setId(11L);
blog.setTitle("mapp");
String jsonStr = objectMapper.writeValueAsString(blog);//对象转成json字符串
M