gpt4 book ai didi

spring-boot - spring-boot-starter-data-redis无法正常工作

转载 作者:行者123 更新时间:2023-12-02 04:38:01 25 4
gpt4 key购买 nike

我使用的是Spring Boot 1.4.1,所以我有spring-boot-starter-data-redis
pom.xml文件是这样的:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

这是主类:
@SpringBootApplication
public class App {
public static void main(String[] args) {
new SpringApplicationBuilder(App.class).web(true).run(args);
}
}

这是要测试的 Controller 类:
@RestController
public class CommonTestCtrl {
@Autowired
private RedisTemplate<Object, Object> template;

@Autowired
private StringRedisTemplate stringRedisTemplate;

@RequestMapping(value = "/redisGet", method = RequestMethod.GET)
public String getRedisValue(@RequestParam(value = "key", required = false) String key) {
// not OK
this.template.opsForValue().set(888888, 188);
// OK
this.stringRedisTemplate.opsForValue().set(key + "String", "stringRedisTemplate");
return "";
}
}

我发现this.template.opsForValue()。set(888888,188);不会保存任何东西来重做。为什么?

这是CODE URL: https://github.com/eacdy/test2

你可以帮帮我吗?多谢。

最佳答案

我从spring-boot 1.3.7.RELEASE升级到1.5.10.RELEASE。工件名称从:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>

至:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

关于spring-boot - spring-boot-starter-data-redis无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40282057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com