小编yo_*_*nas的帖子

如何自动连接RedisTemplate <String,Long>

我想在春季启动时使用RedisTemplate.我可以成功使用StringRedeisTemplate,但是当我无法使用RedisTemplate时.这是代码.

@Service
public class MyService {

    @Autowired
    private RedisTemplate<String, Long> template;

    public void execute() {
        template.opsForValue().set("hoge", 1l);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当启动应用程序时,会出错.

> Exception in thread "main"
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'MyService': Injection of autowired
> dependencies failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Could not
> autowire field: private
> org.springframework.data.redis.core.RedisTemplate
> org.hoge.service.MyService.template; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
> qualifying bean of type
> [org.springframework.data.redis.core.RedisTemplate] found for
> dependency: expected at least 1 bean which qualifies as …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc redis

9
推荐指数
1
解决办法
2万
查看次数

我们可以禁止使用 || lint 的可选类型?

我想禁止以下代码:

function(num: undefined|number) {
  return num || 10;
}
Run Code Online (Sandbox Code Playgroud)

我想使用??而不是||.

typescript eslint typescript-eslint

2
推荐指数
1
解决办法
65
查看次数