我有一个运行127.0.0.1:6379
的本地Redis服务器
在为配置创建模板时,它不是在创建模板
@Configuration
public class AWSRedisCacheConfig {
@Bean
JedisConnectionFactory jedisConnectionFactory() {
PropObjectLoader propObjectLoader = new PropObjectLoader();
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(propObjectLoader.getPropertyValue("elastic.redis.hostname"),Integer.parseInt(propObjectLoader.getPropertyValue("elastic.redis.port")));
return new JedisConnectionFactory(redisStandaloneConfiguration);
}
@Bean(name = {"redisTemplate"})
public RedisTemplate<String, Object> redisTemplate() {
PropObjectLoader propObjectLoader = new PropObjectLoader();
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(propObjectLoader.getPropertyValue("elastic.redis.hostname"),Integer.parseInt(propObjectLoader.getPropertyValue("elastic.redis.port")));
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(new JedisConnectionFactory(redisStandaloneConfiguration));
return redisTemplate;
}
}
我已经创建了Redis模板并尝试创建模板对象,但是在 spring mvc4.5
中没有发生提前谢谢