Spring MVC Redis缓存模板配置错误

时间:2019-03-15 06:49:49

标签: java spring-mvc redis

我有一个运行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

中没有发生

提前谢谢

0 个答案:

没有答案