{"id":8402,"date":"2023-11-28T20:27:14","date_gmt":"2023-11-28T12:27:14","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8402"},"modified":"2023-12-06T10:28:15","modified_gmt":"2023-12-06T02:28:15","slug":"springboot-zhong-ru-he-jin-xing-fu-wu-jian-kong-yu","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springboot-zhong-ru-he-jin-xing-fu-wu-jian-kong-yu\/","title":{"rendered":"SpringBoot\u4e2d\u5982\u4f55\u8fdb\u884c\u670d\u52a1\u76d1\u63a7\u4e0e\u7ba1\u7406\uff1f"},"content":{"rendered":"<p>Spring Boot \u63d0\u4f9b\u4e86 Spring Boot Actuator \u6a21\u5757\u6765\u8fdb\u884c\u670d\u52a1\u76d1\u63a7\u548c\u7ba1\u7406\u3002Actuator \u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5185\u7f6e\u7684\u7ba1\u7406\u7aef\u70b9\uff0c\u901a\u8fc7\u8fd9\u4e9b\u7aef\u70b9\u53ef\u4ee5\u67e5\u770b\u5e94\u7528\u7a0b\u5e8f\u7684\u8fd0\u884c\u72b6\u51b5\u3001\u914d\u7f6e\u4fe1\u606f\u3001\u65e5\u5fd7\u7b49\uff0c\u4ee5\u53ca\u6267\u884c\u4e00\u4e9b\u7ba1\u7406\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 Actuator \u7aef\u70b9\u548c\u914d\u7f6e\uff1a<\/p>\n<ol>\n<li>\n<strong>\u5065\u5eb7\u68c0\u67e5 <code>\/actuator\/health<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u63d0\u4f9b\u5e94\u7528\u7a0b\u5e8f\u7684\u5065\u5eb7\u68c0\u67e5\u4fe1\u606f\uff0c\u53ef\u4ee5\u7528\u4e8e\u67e5\u770b\u5e94\u7528\u7a0b\u5e8f\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u53ef\u4ee5\u914d\u7f6e\u8be6\u7ec6\u7684\u5065\u5eb7\u68c0\u67e5\u89c4\u5219\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">management:\n  endpoint:\n    health:\n      show-details: always\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u4fe1\u606f\u7aef\u70b9 <code>\/actuator\/info<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u63d0\u4f9b\u81ea\u5b9a\u4e49\u7684\u5e94\u7528\u7a0b\u5e8f\u4fe1\u606f\u3002\u53ef\u4ee5\u5728 <code>application.properties<\/code> \u6216 <code>application.yml<\/code> \u6587\u4ef6\u4e2d\u914d\u7f6e\u81ea\u5b9a\u4e49\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">info:\n  app:\n    name: MySpringBootApp\n    description: This is a Spring Boot application.\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u73af\u5883\u4fe1\u606f\u7aef\u70b9 <code>\/actuator\/env<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u63d0\u4f9b\u5e94\u7528\u7a0b\u5e8f\u7684\u73af\u5883\u4fe1\u606f\uff0c\u5305\u62ec\u914d\u7f6e\u5c5e\u6027\u3001\u7cfb\u7edf\u5c5e\u6027\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u914d\u7f6e\u4fe1\u606f\u7aef\u70b9 <code>\/actuator\/configprops<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u663e\u793a\u6240\u6709\u53ef\u7528\u7684\u914d\u7f6e\u5c5e\u6027\u53ca\u5176\u6e90\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u65e5\u5fd7\u7ea7\u522b\u4fee\u6539\u7aef\u70b9 <code>\/actuator\/loggers<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u5141\u8bb8\u52a8\u6001\u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u7684\u65e5\u5fd7\u7ea7\u522b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u7ebf\u7a0b\u6808\u8ddf\u8e2a\u7aef\u70b9 <code>\/actuator\/threaddump<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u8f93\u51fa\u7ebf\u7a0b\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u5237\u65b0\u914d\u7f6e\u7aef\u70b9 <code>\/actuator\/refresh<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u89e6\u53d1\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u5c5e\u6027\u503c\uff0c\u9002\u7528\u4e8e\u52a8\u6001\u8c03\u6574\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">management:\n  endpoints:\n    web:\n      exposure:\n        include: refresh\n<\/code><\/pre>\n<\/li>\n<li>\n<strong>\u5173\u95ed\u5e94\u7528\u7a0b\u5e8f\u7aef\u70b9 <code>\/actuator\/shutdown<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u5141\u8bb8\u901a\u8fc7\u53d1\u9001 POST \u8bf7\u6c42\u6765\u5173\u95ed\u5e94\u7528\u7a0b\u5e8f\u3002\u9700\u8981\u5728 <code>application.properties<\/code> \u6216 <code>application.yml<\/code> \u4e2d\u914d\u7f6e\u7aef\u70b9\u7684\u5f00\u542f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">management:\n  endpoint:\n    shutdown:\n      enabled: true\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u542f\u7528 Actuator \u7aef\u70b9\u7684\u65b9\u5f0f\u6709\u4e24\u79cd\uff1a<\/p>\n<ol>\n<li>\n<strong>\u81ea\u52a8\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 Spring Boot \u5e94\u7528\u7a0b\u5e8f\u7684 classpath \u4e0b\uff0c\u5305\u542b <code>spring-boot-starter-actuator<\/code> \u4f9d\u8d56\uff0cActuator \u5c06\u81ea\u52a8\u914d\u7f6e\u4e3a\u542f\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u624b\u52a8\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u9700\u8981\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\uff0c\u53ef\u4ee5\u5728 <code>application.properties<\/code> \u6216 <code>application.yml<\/code> \u4e2d\u663e\u5f0f\u914d\u7f6e Actuator \u7aef\u70b9\u7684\u5f00\u542f\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-yaml\">management:\n  endpoints:\n    web:\n      exposure:\n        include: health,info,env,configprops,loggers,threaddump,refresh,shutdown\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e00\u4e9b\u654f\u611f\u7684\u7aef\u70b9\u9ed8\u8ba4\u662f\u5173\u95ed\u7684\uff0c\u9700\u8981\u5728\u914d\u7f6e\u4e2d\u663e\u5f0f\u5f00\u542f\u3002\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u5e94\u8c28\u614e\u5f00\u542f\u4e00\u4e9b\u5177\u6709\u6f5c\u5728\u98ce\u9669\u7684\u7aef\u70b9\uff0c\u4f8b\u5982 <code>\/shutdown<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot \u63d0\u4f9b\u4e86 Spring Boot Actuator \u6a21\u5757\u6765\u8fdb\u884c\u670d\u52a1\u76d1\u63a7\u548c\u7ba1\u7406\u3002Actua [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[],"class_list":["post-8402","post","type-post","status-publish","format-standard","hentry","category-springboot"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=8402"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8402\/revisions"}],"predecessor-version":[{"id":16608,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8402\/revisions\/16608"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8402"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}