springboot启动时自动检测mysql,redis是否可用

在工程中引入

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
依赖
这样在启动的时候就会对mysql和redis进行健康检查】
2022-01-28 14:56:49.910 info 87856 nacos-provider --- [] [3)-10.100.10.92] 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)
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:348)
    at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:129)

如果链接不可用,就会报相应的链接错误

posted @ 2022-01-28 14:59  龌龊猫  阅读(1855)  评论(0编辑  收藏  举报