W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
您可以通過創(chuàng)建StubDownloaderBuilder
接口的實(shí)現(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 } }
然后,可以將其注冊(cè)到spring.factories
文件中,如以下示例所示:
# Example of a custom Stub Downloader Provider org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder=\ com.example.CustomStubDownloaderBuilder
現(xiàn)在,您可以選擇一個(gè)包含存根源的文件夾。
如果不提供任何實(shí)現(xiàn),則使用默認(rèn)設(shè)置(掃描類路徑)。如果提供
stubsMode = StubRunnerProperties.StubsMode.LOCAL
或, stubsMode = StubRunnerProperties.StubsMode.REMOTE
,則將使用Aether實(shí)現(xiàn)。如果提供多個(gè)??,則將使用列表中的第一個(gè)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: