Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem if the SpringBoot actuator health check doesn't pass?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "SpringBoot actuator health examination does not pass how to solve". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

SpringBoot actuator health check failed.

Today, I encountered a service that was able to register successfully, but the health check failed. The network of the url,chrome that accesses the health check through the browser keeps displaying pending, indicating that the request has been submitted, but it cannot be returned, and it is stuck.

It was thought that the health check is to check whether the request / health under the service port can be returned normally, but it is not.

The so-called health check has many check items. For classes that inherit AbstractHealthIndicator in springboot, such as DataSourceHealthIndicator RedisHealthIndicator, springboot will be automatically configured. For example, if mysql's datasouce is used, DataSourceHealthIndicator's doHealthCheck () will be executed during health check, and RedisHealthIndicator's doHealthCheck () will be executed if redis is used.

Solution:

First of all, you can determine whether these external data sources are unable to connect and cause the health check to fail, and you can configure

Management: health: db: enabled: false redis: enabled: false elasticsearch: enabled: false

Turn off the health check for everything used in the system to see if the health check can pass normally, if you can turn it on one by one and eliminate the problem one by one.

Finally, it is found that the above pending situation is due to the incorrect url configuration of mysql, such as incorrect port, or insufficient permissions of the mysql user, and the doHealthCheck () of DataSourceHealthIndicator will connect to mysql unsuccessfully, so it will be stuck in the connection to mysql.

Configure the correct url, turn on permissions, and solve the problem.

Spring Boot health check related configuration and arrangement 1. What is the health check of Spring Boot and what is the use?

Spring Boot provides health checks for multiple components, which is helpful to monitor the health status of various components, but sometimes developers will start unsuccessfully, report errors, etc., and need to be configured reasonably.

What checks are available in the 2.Spring Boot project and how to configure them:

2.1 the first package introduced by health check is

Org.springframework.boot spring-boot-starter-actuator

2.2 related health check-related Indicator

CassandraHealthIndicator checks if Cassandra is available

DiskSpaceHealthIndicator checks if there is not enough disk space.

DataSourceHealthIndicator checks if you can get a link from DataSource

ElasticsearchHealthIndicator checks if Elasticsearch cluste is available

JmsHealthIndicator checks if JMS broker is available

MailHealthIndicator checks if mail server is available

MongoHealthIndicator checks if Mongo database is available

RabbitHealthIndicator checks if Rabbit server is available

RedisHealthIndicator checks if Redis server is available

SolrHealthIndicator checks if Solr server is available

As you can see, there are checks of various external services. For details, please browse the official documents. There is no need to spare any more here.

2.3 how to turn off / turn on health check

Explicit setting in application.properties

/ / if the health check of es is prohibited as follows, management.health.elasticsearch.enabled=false is enabled by default.

You can also use * ban it all.

This is the end of management.health.*.enabled=false 's "SpringBoot actuator Health check does not pass how to solve". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report