返回信息流想用多线程测试下redis的单线程,但是这段程序在main下面可以正常运行,在test下面却报错org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: Connection is closed
是不是我没引入某些配置呀?
目前只有
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = StoredemoApplication.class)
new Thread() {
public void run() {
try {
redisTemplate.opsForValue().set("test", "test");
}catch (Exception e){
System.out.println(e);
}
}
}.start();
这是一条镜像帖。来源:北邮人论坛 / java / #63956同步于 2020/6/14
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
在spring test下出现redis connection closed的情况
hyforever
2020/6/14镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
我只在application. Yml里面配置了,但是在我用@springboottest()的时候应该已经引入了呀?
我正常的在test里面调用redistemplate是没问题的,就是想用new thread起线程测试不行
【 在 qingliu 的大作中提到: 】
:Test 目录配了 redis 相关配置了吗
redis 你是autowired的?不起线程在test 类下面redis可以正常操作?不能就加配置
【 在 hyforever (【意涵团】宝宝龙) 的大作中提到: 】
: 我只在application. Yml里面配置了,但是在我用@springboottest()的时候应该已经引入了呀?
: 我正常的在test里面调用redistemplate是没问题的,就是想用new thread起线程测试不行
把线程阻塞一下,这个test结束 线程就没了,链接就断了
【 在 qingliu 的大作中提到: 】
: redis 你是autowired的?不起线程在test 类下面redis可以正常操作?不能就加配置