如何在 Micronaut 中注入 StringRedisTemplate?

问题描述

我尝试创建一个 redis 管理器来检查 Id 是否已经存在于 redis 中。为此,我注入了 StringRedistemplate -

@Singleton
public class RedisManager {

    @Inject
    private StringRedistemplate redistemplate;


    public String getKey(String userProfileId) {
        return redistemplate.opsForValue().get(getRedisKey(Id));
    }
}

但是在尝试 GET 请求时,我收到此错误-

"message": "Internal Server Error: Failed to inject value for field [redistemplate] of class: com.micronaut.oyomoney.redis.RedisManager\n\nPath Taken: BookController.BookService --> $BookServiceDeFinition$Intercepted.redisManager --> RedisManager.redistemplate"

我该如何解决这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)