我想在春季启动时使用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) 我想禁止以下代码:
function(num: undefined|number) {
return num || 10;
}
Run Code Online (Sandbox Code Playgroud)
我想使用??而不是||.