本文整理汇总了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;
}
示例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));
}
示例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());
}
示例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();
}
示例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));
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}