當前位置: 首頁>>代碼示例>>Java>>正文


Java RestTemplateBuilder類代碼示例

本文整理匯總了Java中org.springframework.boot.web.client.RestTemplateBuilder的典型用法代碼示例。如果您正苦於以下問題:Java RestTemplateBuilder類的具體用法?Java RestTemplateBuilder怎麽用?Java RestTemplateBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RestTemplateBuilder類屬於org.springframework.boot.web.client包,在下文中一共展示了RestTemplateBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: arkClient

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Bean
public ArkClient arkClient(Environment environment) {
    // todo: we should probably just network config in json format so it can directly consume ark-node configs
    String arkNetworkName = environment.getProperty("arkNetwork.name");
    ArkNetwork arkNetwork = new ArkNetworkFactory()
        .createFromYml("ark-config/" + arkNetworkName + ".yml");
    
    RestTemplate restTemplate = new RestTemplateBuilder()
        .setConnectTimeout(2000)
        .setReadTimeout(2000)
        .build();

    HttpArkClient httpArkClient = new HttpArkClient(arkNetwork, restTemplate);
    httpArkClient.updatePeers();

    return httpArkClient;
}
 
開發者ID:ark-aces,項目名稱:aces-backend,代碼行數:18,代碼來源:ApplicationConfig.java

示例2: beforeClass

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
    jettyServer = new Server(0);

    WebAppContext webApp = new WebAppContext();
    webApp.setServer(jettyServer);
    webApp.setContextPath(CONTEXT_PATH);
    webApp.setWar("src/test/webapp");

    jettyServer.setHandler(webApp);
    jettyServer.start();
    serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();

    testRestTemplate = new TestRestTemplate(new RestTemplateBuilder()
            .rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
 
開發者ID:opentracing-contrib,項目名稱:java-spring-web,代碼行數:17,代碼來源:MVCJettyITest.java

示例3: MovieRepository

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
/**
 * Construct rest template with data app uri.
 *
 * @param builder    rest template builder
 * @param dataAppUri data app uri from application.properties
 */
public MovieRepository(RestTemplateBuilder builder, @Value("${moviedb.webapp.dataAppUri}") String dataAppUri) {
    logger.debug("data app:" + dataAppUri);

    String trimmedURL = dataAppUri.trim().toLowerCase();
    String dataAppApiUrl;
    if (trimmedURL.startsWith("http://") || trimmedURL.startsWith("https://")) {
        dataAppApiUrl = trimmedURL + "/api/v1";
    } else {
        dataAppApiUrl = "http://" + trimmedURL + "/api/v1";
    }

    logger.debug("data app api root url: " + dataAppApiUrl);
    restTemplate = builder.rootUri(dataAppApiUrl).build();
    restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
}
 
開發者ID:Microsoft,項目名稱:movie-db-java-on-azure,代碼行數:22,代碼來源:MovieRepository.java

示例4: bitcoinRpcRestTemplate

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Bean
public RestTemplate bitcoinRpcRestTemplate(BitcoinRpcSettings bitcoinRpcSettings) {
    return new RestTemplateBuilder()
        .rootUri(bitcoinRpcSettings.getUrl())
        .basicAuthorization(bitcoinRpcSettings.getUsername(), bitcoinRpcSettings.getPassword())
        .build();
}
 
開發者ID:ark-aces,項目名稱:aces-listener-bitcoin,代碼行數:8,代碼來源:ApplicationConfig.java

示例5: restApiGetStatus

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Test
public void restApiGetStatus() throws Exception {
  exit.expectSystemExitWithStatus(0);

  runner = WaggleDanceRunner
      .builder(configLocation)
      .primary("primary", localServer.getThriftConnectionUri(), READ_ONLY)
      .federate("waggle_remote", remoteServer.getThriftConnectionUri(), REMOTE_DATABASE)
      .build();

  runWaggleDance(runner);

  RestTemplate rest = new RestTemplateBuilder().build();
  PrimaryMetaStore primaryMetastore = rest.getForObject("http://localhost:18000/api/admin/federations/primary",
      PrimaryMetaStore.class);
  assertThat(primaryMetastore.getStatus(), is(MetaStoreStatus.AVAILABLE));
  FederatedMetaStore federatedMetastore = rest
      .getForObject("http://localhost:18000/api/admin/federations/waggle_remote", FederatedMetaStore.class);
  assertThat(federatedMetastore.getStatus(), is(MetaStoreStatus.AVAILABLE));
}
 
開發者ID:HotelsDotCom,項目名稱:waggle-dance,代碼行數:21,代碼來源:WaggleDanceIntegrationTest.java

示例6: wxApiTemplate

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
/**
 * 是否有必要模仿Spring不提供RestTemplate,隻提供RestTemplateBuilder
 *
 * @return dummy
 */
@Bean(name = WxBeans.WX_API_TEMPLATE_NAME)
public WxApiTemplate wxApiTemplate() {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    builder = builder.requestFactory(new WxApiHttpRequestFactory(wxProperties))
            .errorHandler(new WxResponseErrorHandler());
    HttpMessageConverters converters = this.messageConverters.getIfUnique();
    List<HttpMessageConverter<?>> converterList = new ArrayList<>();
    // 加入默認轉換
    converterList.add(new WxHttpInputMessageConverter());
    if (converters != null) {
        converterList.addAll(converters.getConverters());
        builder = builder.messageConverters(Collections.unmodifiableList(converterList));
    }
    return new WxApiTemplate(builder.build());
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:21,代碼來源:WxInvokerConfiguration.java

示例7: restTemplateBuilder

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public RestTemplateBuilder restTemplateBuilder() {
	RestTemplateBuilder builder = new RestTemplateBuilder();
	HttpMessageConverters converters = this.messageConverters.getIfUnique();
	if (converters != null) {
		builder = builder.messageConverters(converters.getConverters());
	}
	List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers
			.getIfAvailable();
	if (!CollectionUtils.isEmpty(customizers)) {
		customizers = new ArrayList<RestTemplateCustomizer>(customizers);
		AnnotationAwareOrderComparator.sort(customizers);
		builder = builder.customizers(customizers);
	}
	return builder;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:WebClientAutoConfiguration.java

示例8: proxyExchangeArgumentResolver

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public ProxyExchangeArgumentResolver proxyExchangeArgumentResolver(
		Optional<RestTemplateBuilder> optional, ProxyProperties proxy) {
	RestTemplateBuilder builder = optional.orElse(new RestTemplateBuilder());
	RestTemplate template = builder.build();
	template.setErrorHandler(new NoOpResponseErrorHandler());
	template.getMessageConverters().add(new ByteArrayHttpMessageConverter() {
		@Override
		public boolean supports(Class<?> clazz) {
			return true;
		}
	});
	ProxyExchangeArgumentResolver resolver = new ProxyExchangeArgumentResolver(
			template);
	resolver.setHeaders(proxy.convertHeaders());
	resolver.setSensitive(proxy.getSensitive()); // can be null
	return resolver;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-gateway,代碼行數:20,代碼來源:ProxyResponseAutoConfiguration.java

示例9: ProjectGenerationStatPublisher

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
public ProjectGenerationStatPublisher(ProjectRequestDocumentFactory documentFactory,
		StatsProperties statsProperties, RestTemplateBuilder restTemplateBuilder,
		RetryTemplate retryTemplate) {
	this.documentFactory = documentFactory;
	this.statsProperties = statsProperties;
	this.objectMapper = createObjectMapper();
	StatsProperties.Elastic elastic = statsProperties.getElastic();
	if (StringUtils.hasText(elastic.getUsername())) {
		this.restTemplate = restTemplateBuilder
				.basicAuthorization(elastic.getUsername(),
						elastic.getPassword())
				.build();
	} else {
		this.restTemplate = restTemplateBuilder.build();
	}
	this.retryTemplate = retryTemplate;
}
 
開發者ID:spring-io,項目名稱:initializr,代碼行數:18,代碼來源:ProjectGenerationStatPublisher.java

示例10: setUp

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Before
public void setUp()
{
	log = mock(Log.class);
	when(log.isDebugEnabled()).thenReturn(true);
	
	restTemplate = new RestTemplateBuilder()
		.customizers(new LoggingCustomizer(log))
		.rootUri(wireMockRule.url("/"))
		.build();
}
 
開發者ID:markhobson,項目名稱:spring-rest-template-logger,代碼行數:12,代碼來源:LoggingCustomizerIT.java

示例11: setup

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Before
public void setup() {
	// setup
	WireMock.startRecording(configure(WireMock.recordSpec())
			.extractTextBodiesOver(9999999L)
			.extractBinaryBodiesOver(9999999L)
			.makeStubsPersistent(false)
	);
	restTemplate = configure(new RestTemplateBuilder())
			.rootUri("http://localhost:" + wireMockPort)
			.build();
}
 
開發者ID:marcingrzejszczak,項目名稱:the-legacy-app,代碼行數:13,代碼來源:AbstractStubsFromProxy.java

示例12: restTemplate

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
private RestTemplate restTemplate(ReleaserProperties properties) {
	Assert.hasText(properties.getGit().getOauthToken(), "In order to connect to Sagan you need to pass the Github OAuth token. "
			+ "You can do it via the [--releaser.git.oauth-token=...] command line argument or an env variable [export RELEASER_GIT_OAUTH_TOKEN=...].");
	return new RestTemplateBuilder()
			.basicAuthorization(properties.getGit().getOauthToken(), "")
			.build();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-release-tools,代碼行數:8,代碼來源:SaganConfiguration.java

示例13: SubmissionSenderService

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
@Autowired
public SubmissionSenderService(RestTemplateBuilder restTemplateBuilder,
    SandboxSubmissionProperties sandboxSubmissionProperties) {
  this.sandboxSubmissionProperties = sandboxSubmissionProperties;

  restTemplate = restTemplateBuilder
      .rootUri(sandboxSubmissionProperties.getSandboxUrl())
      .build();
}
 
開發者ID:tdd-pingis,項目名稱:tdd-pingpong,代碼行數:10,代碼來源:SubmissionSenderService.java

示例14: AlfredServiceImpl

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
AlfredServiceImpl(final RestTemplateBuilder restTemplateBuilder,
                  final NodeReferenceBuilder nodeReferenceBuilder,
                  final String url,
                  final String username,
                  final String password) {
    this.nodeReferenceBuilder = nodeReferenceBuilder;
    this.url = url;
    restTemplate = restTemplateBuilder.build();
    // restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
    restTemplate.getInterceptors().add(
            new BasicAuthorizationInterceptor(username, password != null ? password : ""));
    logger.debug("Creation of AlfredServiceImpl for URL {}", url);
}
 
開發者ID:avdyk,項目名稱:be.liege.cti.ged,代碼行數:15,代碼來源:AlfredServiceImpl.java

示例15: PensionFundStatisticsService

import org.springframework.boot.web.client.RestTemplateBuilder; //導入依賴的package包/類
public PensionFundStatisticsService(RestTemplateBuilder restTemplateBuilder) {
  restTemplate = restTemplateBuilder
      .setConnectTimeout(30_000)
      .setReadTimeout(60_000)
      .additionalMessageConverters(new Jaxb2RootElementHttpMessageConverter())
    .build();
}
 
開發者ID:TulevaEE,項目名稱:onboarding-service,代碼行數:8,代碼來源:PensionFundStatisticsService.java


注:本文中的org.springframework.boot.web.client.RestTemplateBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。