W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
您可以通過創(chuàng)建StubDownloaderBuilder
接口的實現(xiàn)來自定義存根的下載方式,如以下示例所示:
package com.example; class CustomStubDownloaderBuilder implements StubDownloaderBuilder { @Override public StubDownloader build(final StubRunnerOptions stubRunnerOptions) { return new StubDownloader() { @Override public Map.Entry<StubConfiguration, File> downloadAndUnpackStubJar( StubConfiguration config) { File unpackedStubs = retrieveStubs(); return new AbstractMap.SimpleEntry<>( new StubConfiguration(config.getGroupId(), config.getArtifactId(), version, config.getClassifier()), unpackedStubs); } File retrieveStubs() { // here goes your custom logic to provide a folder where all the stubs reside } }
然后,可以將其注冊到spring.factories
文件中,如以下示例所示:
# Example of a custom Stub Downloader Provider org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder=\ com.example.CustomStubDownloaderBuilder
現(xiàn)在,您可以選擇一個包含存根源的文件夾。
如果不提供任何實現(xiàn),則使用默認(rèn)設(shè)置(掃描類路徑)。如果提供
stubsMode = StubRunnerProperties.StubsMode.LOCAL
或, stubsMode = StubRunnerProperties.StubsMode.REMOTE
,則將使用Aether實現(xiàn)。如果提供多個??,則將使用列表中的第一個。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: