宅男在线永久免费观看网直播,亚洲欧洲日产国码无码久久99,野花社区在线观看视频,亚洲人交乣女bbw,一本一本久久a久久精品综合不卡

全部
常見問題
產品動態(tài)
精選推薦

在傳統(tǒng)Spring應用中使用spring-boot-actuator模塊提供監(jiān)控端點

管理 管理 編輯 刪除

第一步:引入相關依賴

由于在傳統(tǒng)Spring應用中,我們不能直接使用Starter POMs。所以,我們需要拆解了來引入到傳統(tǒng)Spring應用的pom.xml中,主要有如下兩個依賴:


<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator</artifactId>
    <version>1.4.3.RELEASE</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.3.2.Final</version>
</dependency>

#第二部:手工引入配置

由于在傳統(tǒng)Spring應用中沒有自動化配置功能,所以我們需要手工的來創(chuàng)建配置并啟用Spring Boot Actuator的監(jiān)控端點。比如,我們先來創(chuàng)建一個實現(xiàn)/health端點的配置,具體如下:


@Configuration
@Import({ EndpointAutoConfiguration.class,
        HealthIndicatorAutoConfiguration.class})
public class MyAppSpringConfig {

    @Bean
    public EndpointHandlerMapping endpointHandlerMapping(
            Collection<? extends MvcEndpoint> endpoints) {
        return new EndpointHandlerMapping(endpoints);
    }

    @Bean
    public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) {
        return new HealthMvcEndpoint(delegate, false);
    }

}

其中,@Import中引入的org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration類是Spring Boot Actuator的基礎配置類。org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration類是/health端點的基礎配置,具體內容本文不做詳細展開,讀者可自行查看。而在該配置類中,還創(chuàng)建了兩個Bean,其中EndpointHandlerMappingorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping的子類,它用來加載所有的監(jiān)控端點;而HealthMvcEndpoint是具體的/health端點實現(xiàn)。

在完成上面配置之后,我們就可以啟動Spring應用,此時就可以看控制臺中看到打印出了/health端點,我們可以嘗試訪問該端點來獲取當前實例的健康狀況。

除了在傳統(tǒng)應用中可以加載/health端點之外,我們也可以如法炮制地創(chuàng)建其他端點,比如:獲取各個度量指標的/metrics端點,可以通過如下配置實現(xiàn):


@Configuration
@Import({ EndpointAutoConfiguration.class,
        PublicMetricsAutoConfiguration.class,
        HealthIndicatorAutoConfiguration.class})
public class MyAppSpringConfig {

    @Bean
    public EndpointHandlerMapping endpointHandlerMapping(
            Collection<? extends MvcEndpoint> endpoints) {
        return new EndpointHandlerMapping(endpoints);
    }

    @Bean
    public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) {
        return new HealthMvcEndpoint(delegate, false);
    }

    @Bean
    public EndpointMvcAdapter metricsEndPoint(MetricsEndpoint delegate) {
        return new EndpointMvcAdapter(delegate);
    }
  
}



這里,我們主要增加了兩個內容:

  • @Import中增加引入PublicMetricsAutoConfiguration配置類
  • 創(chuàng)建/metrics端點的實現(xiàn)Bean


請登錄后查看

CRMEB 最后編輯于2025-01-22 17:26:44

快捷回復
回復
回復
回復({{post_count}}) {{!is_user ? '我的回復' :'全部回復'}}
排序 默認正序 回復倒序 點贊倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理員 企業(yè)

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
{{item.is_suggest == 1? '取消推薦': '推薦'}}
沙發(fā) 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暫無簡介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打賞
已打賞¥{{item.reward_price}}
{{item.like_count}}
{{item.showReply ? '取消回復' : '回復'}}
刪除
回復
回復

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回復 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打賞
已打賞¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回復' : '回復'}}
刪除
回復
回復
查看更多
打賞
已打賞¥{{reward_price}}
896
{{like_count}}
{{collect_count}}
添加回復 ({{post_count}})

相關推薦

快速安全登錄

使用微信掃碼登錄
{{item.label}} 加精
{{item.label}} {{item.label}} 板塊推薦 常見問題 產品動態(tài) 精選推薦 首頁頭條 首頁動態(tài) 首頁推薦
取 消 確 定
回復
回復
問題:
問題自動獲取的帖子內容,不準確時需要手動修改. [獲取答案]
答案:
提交
bug 需求 取 消 確 定
打賞金額
當前余額:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
請輸入 0.1-{{reward_max_price}} 范圍內的數(shù)值
打賞成功
¥{{price}}
完成 確認打賞

微信登錄/注冊

切換手機號登錄

{{ bind_phone ? '綁定手機' : '手機登錄'}}

{{codeText}}
切換微信登錄/注冊
暫不綁定
CRMEB客服

CRMEB咨詢熱線 咨詢熱線

400-8888-794

微信掃碼咨詢

CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
返回頂部 返回頂部
CRMEB客服