当前位置: 首页>>代码示例>>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;未经允许,请勿转载。