启动报Cannot get Jedis connection,不知道哪里用到了这个服务
来源:3-6 服务异常处理

frank_mac
2017-10-26
2017-10-27 21:11:33.807 INFO 2124 --- [ main] com.start.DemoApplication : Started DemoApplication in 3.703 seconds (JVM running for 5.056)
2017-10-27 21:11:33.968 WARN 2124 --- [)-192.168.1.101] o.s.b.a.health.RedisHealthIndicator : Health check failed
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:204) ~[spring-data-redis-1.8.6.RELEASE.jar:na]
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:348) ~[spring-data-redis-1.8.6.RELEASE.jar:na]
at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:129) ~[spring-data-redis-1.8.6.RELEASE.jar:na]
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:92) ~[spring-data-redis-1.8.6.RELEASE.jar:na]
at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:79) ~[spring-data-redis-1.8.6.RELEASE.jar:na]
at org.springframework.boot.actuate.health.RedisHealthIndicator.doHealthCheck(RedisHealthIndicator.java:52) ~[spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:43) ~[spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:68) [spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:85) [spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.actuate.endpoint.HealthEndpoint.invoke(HealthEndpoint.java:35) [spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean.getData(DataEndpointMBean.java:46) [spring-boot-actuator-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) [na:1.8.0_121]
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) [na:1.8.0_121]
2017-10-27 21:11:33.807 INFO 2124 --- [ main] com.start.DemoApplication : Started DemoApplication in 3.703 seconds (JVM running for 5.056)
2017-10-27 21:11:33.968 WARN 2124 --- [)-192.168.1.101] o.s.b.a.health.RedisHealthIndicator : Health check failed
2回答
-
frank_mac
提问者
2017-10-27
你们跟着敲的时候没遇到同样的问题????
后来仔细看了一下,发现服务其实启动成功了,报错的是:
o.s.b.a.health.RedisHealthIndicator : Health check failed
于是跟进源码,发现RedisHealthIndicator属于
org.springframework.boot.actuate.health
原来是springboot的组件连结的健康检查监控,既然这样,应该是可以配置关闭检查的,但是怎么关,上官网,就搜 RedisHealthIndicator,没想到还真有。
**
It is possible to disable them all using the management.health.defaults.enabled property.
**
可以disable的
再搜
management.health.defaults.enabled还真有
这个是默认 是Enable default health indicators,下面还有一个management.health.redis.enabled,那直接在application.properties中加入management.health.redis.enabled=false。restart,果然没问题了。
原来项目中依赖了spring-boot-starter-data-redis,看来依赖了redis,他会默认去检查连接,但是3-6课还没有使用redis,所以还没配置连接属性。
接着我想直接把这个包干掉,应该也不会有连结检查了,然后删掉了core的pom中的spring-boot-starter-data-redis依赖,结果项目报错,发现UserController的Pageable是spring-boot-starter-data-redis的spring-data-common中的,先删除试一下,restart,发现也成功了。
考虑到后面会用到redis,于是恢复了代码,然后现将redis的健康检查disabled:
application.properties中加入management.health.redis.enabled=false
这个坑,看视频的时候居然没有出现,很奇怪。
422017-12-05 -
mjka5632
2018-01-03
非常感谢,大神自问自答,有帮助 ~!哈哈
00
Spring Security技术栈开发企业级认证与授权
2662 学习 · 1561 问题
相似问题