W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
從Sleuth
2.0.0
開始,我們不再注冊AsyncRestTemplate
類型的bean。 創(chuàng)建這樣的bean取決于您。然后我們對其進(jìn)行檢測。
要阻止AsyncRestTemplate
功能,請將spring.sleuth.web.async.client.enabled
設(shè)置為false
。要禁用默認(rèn)TraceAsyncClientHttpRequestFactoryWrapper
的創(chuàng)建,請將spring.sleuth.web.async.client.factory.enabled
設(shè)置為false
。
如果根本不想創(chuàng)建AsyncRestClient
,請將spring.sleuth.web.async.client.template.enabled
設(shè)置為false
。
有時您需要使用異步實現(xiàn)模板的多個實現(xiàn)。在以下代碼段中,您可以看到一個如何設(shè)置這樣的自定義AsyncRestTemplate
的示例:
@Configuration @EnableAutoConfiguration static class Config { @Bean(name = "customAsyncRestTemplate") public AsyncRestTemplate traceAsyncRestTemplate() { return new AsyncRestTemplate(asyncClientFactory(), clientHttpRequestFactory()); } private ClientHttpRequestFactory clientHttpRequestFactory() { ClientHttpRequestFactory clientHttpRequestFactory = new CustomClientHttpRequestFactory(); // CUSTOMIZE HERE return clientHttpRequestFactory; } private AsyncClientHttpRequestFactory asyncClientFactory() { AsyncClientHttpRequestFactory factory = new CustomAsyncClientHttpRequestFactory(); // CUSTOMIZE HERE return factory; } }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: