Consider defining a bean of type 'redis.clients.jedis.JedisPool' in your configuration.
报错信息

原因是没有Jedispool没有注入


import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig; import java.net.UnknownHostException; @Configuration
public class RedisConfig
{ Logger logger = LogManager.getLogger(RedisConfig.class); @Value("${spring.redis.host}")
private String host; @Value("${spring.redis.port}")
private int port; @Value("${spring.redis.password}")
private String password; @Value("${spring.redis.timeout}")
private int timeout; @Value("${spring.redis.jedis.pool.max-idle}")
private int maxIdle; @Value("${spring.redis.jedis.pool.max-wait}")
private long maxWaitMillis; @Bean
public JedisPool jedisPool()
{
logger.info("JedisPool注入成功!!");
logger.info("redis地址:" + host + ":" + port); JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(maxIdle);
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
return new JedisPool(jedisPoolConfig, host, port, timeout, password);
} @Bean
@SuppressWarnings("all")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)
throws
UnknownHostException
{
// 自定义 String Object
RedisTemplate<String, Object> template = new RedisTemplate();
template.setConnectionFactory(redisConnectionFactory); // Json 序列化配置
Jackson2JsonRedisSerializer<Object> objectJackson2JsonRedisSerializer =
new Jackson2JsonRedisSerializer<Object>(Object.class);
// ObjectMapper 转译
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
objectJackson2JsonRedisSerializer.setObjectMapper(objectMapper); // String 的序列化
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); // key 采用String的序列化方式
template.setKeySerializer(stringRedisSerializer);
// hash 的key也采用 String 的序列化方式
template.setHashKeySerializer(stringRedisSerializer);
// value 序列化方式采用 jackson
template.setValueSerializer(objectJackson2JsonRedisSerializer);
// hash 的 value 采用 jackson
template.setHashValueSerializer(objectJackson2JsonRedisSerializer);
template.afterPropertiesSet(); return template;
}
}
查看一下自己的RedisConfig文件是否有这些内容

Consider defining a bean of type 'redis.clients.jedis.JedisPool' in your configuration.的更多相关文章
- Consider defining a bean of type 'com.lvjing.dao.DeviceStatusMapper' in your configuration.
"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-javaagent:C:\Program Files\JetBra ...
- Spring Boot:Consider defining a bean of type '*.*.*' in your configuration解决方案
果然不看教程直接使用在遇到问题会懵逼,连解决问题都得搜半天还不一定能帮你解决了... ***************************APPLICATION FAILED TO START*** ...
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
超时 Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: jav ...
- redis.clients.jedis.HostAndPort - cant resolve localhost address
阿里云ECS部署spring-boot访问redis出现redis.clients.jedis.HostAndPort - cant resolve localhost address 摘要: 阿里云 ...
- Consider defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration
Description: Parameter 0 of method redisTemplate in com.liaojie.cloud.auth.server.config.redis.Redis ...
- springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.
一.前言: 使用springboot自动注入的方式搭建好了工程,结果启动的时候报错了!!!,错误如下图: Description: Field userEntityMapper in com.xxx. ...
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
搭建完spring boot的demo后自然要实现自动注入来体现spring ioc的便利了,但是我在实施过程中出现了这么一个问题,见下面,这里找到解决办法记录下来,供遇到同样的问题的同僚参考 Des ...
- 记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration
今天遇到的一个问题: 代码检查了好几次,都没有错误,但是启动时就会报错Consider defining a bean of type ''' in your configuration. 启动类在c ...
- Consider defining a bean of type 'package' in your configuration [Spring-Boot]
https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-config ...
随机推荐
- 不太一样的Go Web框架—编程范式
项目地址:https://github.com/Codexiaoyi/linweb 这是一个系列文章: 不太一样的Go Web框架-总览 不太一样的Go Web框架-编程范式 前言 上文说过,linw ...
- python跑机器学习时报错:Process finished with exit code -1073740791 (0xC0000409)
emmm...第二次遇到这个错误了,好好的好好的卷积神经网络突然就跑不起了.就弹出一堆信息也不报那行代码错了... 记录一下: 两次解决方法相同,删h5py包 Process finished wit ...
- CRUSE: Convolutional Recurrent U-net for Speech Enhancement
CRUSE: Convolutional Recurrent U-net for Speech Enhancement 本文是关于TOWARDS EFFICIENT MODELS FOR REAL-T ...
- 新华三Gen10服务器ilo5中刷新bios固件
新华三Gen10服务器ilo5中刷新bios固件. 当前bios1.42 已经是最新了. 固件下载后解压缩. 选择刷新固件. 点击浏览.flash文件. 点击flash 点击ok确认 开始上传 刷新进 ...
- 同时将代码备份到Gitee和GitHub
同时将代码备份到Gitee和GitHub 如何将GitHub项目一步导入Gitee 如何保持Gitee和GitHub同步更新 如何将GitHub项目一步导入Gitee 方法一: 登陆 Gitee 账号 ...
- Linux进程总结
一个执着于技术的公众号 进程 进程,是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础.它的执行需要系统分配资源创建实体之后,才能进行.举个例子: ...
- 好客租房24-react中的事件处理(事件绑定)
3.1事件绑定 React事件绑定语法和DOM事件语法相似 语法:on+事件名称={事件处理程序} 比如οnclick={()=>{}} //导入react import React f ...
- 爬取豆瓣喜剧类热门TOP60的电影
学习任务:爬取豆瓣喜剧类热门TOP60的电影并保存在douban.txt文件中. 代码示例: import requests url="https://movie.douban.com/j/ ...
- 绿色城市智慧运营:Web 3D 垃圾分类 GIS 系统
前言 感谢所有为上海疫情奉献的人,祈求上海疫情早日清零,中国加油,上海加油! <上海市生活垃圾管理条例>施行至今已有两年多,上海市民践行绿色低碳理念.主动参与生活垃圾分类的习惯基本养成,分 ...
- 13. L1,L2范数
讲的言简意赅,本人懒,顺手转载过来:https://www.cnblogs.com/lhfhaifeng/p/10671349.html