stacktrace建议您尚未定义要用于注入的Bean
RedisTemplate。可以解决该问题,创建一个配置文件,例如
import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.data.redis.serializer.GenericToStringSerializer;import org.springframework.data.redis.serializer.StringRedisSerializer;@Configurationpublic class AppConfig { @Bean JedisConnectionFactory jedisConnectionFactory() { return new JedisConnectionFactory(); } @Bean RedisTemplate< String, Long > redisTemplate() { final RedisTemplate< String, Long > template = new RedisTemplate< String, Long >(); template.setConnectionFactory( jedisConnectionFactory() ); template.setKeySerializer( new StringRedisSerializer() ); template.setHashValueSerializer( new GenericToStringSerializer< Long >( Long.class ) ); template.setValueSerializer( new GenericToStringSerializer< Long >( Long.class ) ); return template; }}
SpringApplication.runEg
Object[] sources = {AppConfig.class};ApplicationContext ctx = SpringApplication.run(sources, args);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)