本文整理汇总了Java中org.springframework.cloud.client.loadbalancer.LoadBalanced类的典型用法代码示例。如果您正苦于以下问题:Java LoadBalanced类的具体用法?Java LoadBalanced怎么用?Java LoadBalanced使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoadBalanced类属于org.springframework.cloud.client.loadbalancer包,在下文中一共展示了LoadBalanced类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
@LoadBalanced // 自动负载均衡:他的机制是(通过)Application Name去寻找服务发现,然后去做负载均衡策略的
public RestTemplate restTemplate() {
// HttpComponentsClientHttpRequestFactory httpRequestFactory = new
// HttpComponentsClientHttpRequestFactory();
// httpRequestFactory.setConnectionRequestTimeout(1000);
// httpRequestFactory.setConnectTimeout(1000);
// httpRequestFactory.setReadTimeout(3000);
return new RestTemplate(httpRequestFactory());
}
示例2: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@LoadBalanced
@Bean
RestTemplate restTemplate() {
RestTemplate template = new RestTemplate();
template.setErrorHandler(getResponseErrorHandler());
return template;
}
示例3: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
/**
* Ribbon 経由で Eureka がサポートしているサービスを実行するための RestTemplate。
* <p>リクエスト時に利用者情報を紐づけています。
*/
@Bean
@LoadBalanced
RestTemplate restTemplate(ActorSession session) {
RestTemplate tmpl = new RestTemplate();
tmpl.setInterceptors(new ArrayList<>(Arrays.asList(
new RestActorSessionInterceptor(session)
)));
return tmpl;
}
示例4: ClientCredentialsResourceDetails
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(ClientCredentialsResourceDetails resource) {
ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
clientCredentialsResourceDetails.setClientId(resource.getClientId());
clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
clientCredentialsResourceDetails.setScope(resource.getScope());
clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
return auth2RestTemplate;
}
示例5: ClientCredentialsResourceDetails
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(
ClientCredentialsResourceDetails resource) {
ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
clientCredentialsResourceDetails.setClientId(resource.getClientId());
clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
clientCredentialsResourceDetails.setScope(resource.getScope());
clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
return auth2RestTemplate;
}
开发者ID:kbastani,项目名称:cloud-native-microservice-strangler-example,代码行数:16,代码来源:LegacyEdgeApplication.java
示例6: ShoppingCartServiceV1
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Autowired
public ShoppingCartServiceV1(CartEventRepository cartEventRepository,
@LoadBalanced OAuth2RestTemplate oAuth2RestTemplate,
@LoadBalanced RestTemplate normalRestTemplate) {
this.cartEventRepository = cartEventRepository;
this.oAuth2RestTemplate = oAuth2RestTemplate;
this.restTemplate = normalRestTemplate;
}
示例7: OrderServiceV1
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Autowired
public OrderServiceV1(OrderRepository orderRepository,
OrderEventRepository orderEventRepository,
@LoadBalanced OAuth2RestTemplate oAuth2RestTemplate) {
this.orderRepository = orderRepository;
this.orderEventRepository = orderEventRepository;
this.oAuth2RestTemplate = oAuth2RestTemplate;
}
示例8: maturingServiceUpdater
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
MaturingServiceUpdater maturingServiceUpdater(IngredientsProperties ingredientsProperties,
IngredientWarehouse ingredientWarehouse,
MaturingService maturingService,
@LoadBalanced RestTemplate restTemplate,
EventGateway eventGateway) {
return new MaturingServiceUpdater(ingredientsProperties,
ingredientWarehouse, maturingService, restTemplate, eventGateway);
}
示例9: bottlingServiceUpdater
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
BottlingServiceUpdater bottlingServiceUpdater(Tracer trace, PresentingServiceClient presentingServiceClient,
BottlingService bottlingService,
@LoadBalanced RestTemplate restTemplate,
EventGateway eventGateway) {
return new BottlingServiceUpdater(brewProperties(), trace, presentingServiceClient,
bottlingService, restTemplate, eventGateway);
}
示例10: bottlingService
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
BottlerService bottlingService(BottlingWorker bottlingWorker,
PresentingClient presentingClient,
@LoadBalanced RestTemplate restTemplate,
AsyncRestTemplate asyncRestTemplate,
Tracer tracer) {
return new BottlerService(bottlingWorker, presentingClient, restTemplate, asyncRestTemplate, tracer);
}
示例11: BottlingWorker
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Autowired
public BottlingWorker(Tracer tracer,
PresentingClient presentingClient,
@LoadBalanced RestTemplate restTemplate, EventGateway eventGateway) {
this.tracer = tracer;
this.presentingClient = presentingClient;
this.restTemplate = restTemplate;
this.eventGateway = eventGateway;
}
示例12: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
clientHttpRequestFactory.setReadTimeout(1);
clientHttpRequestFactory.setConnectTimeout(1);
return new RestTemplate(clientHttpRequestFactory);
}
示例13: testAppClient
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
@DependsOnLoadBalancedClient //TODO: can this be avoided?
public TestAppClient testAppClient(@LoadBalanced OkHttpClient.Builder builder) {
Retrofit retrofit = new Retrofit.Builder()
// here you use a service id, or virtual hostname
// rather than an actual host:port, ribbon will
// resolve it
.baseUrl("http://testapp")
.client(builder.build())
.addConverterFactory(JacksonConverterFactory.create())
.build();
return retrofit.create(TestAppClient.class);
}
开发者ID:spring-cloud-incubator,项目名称:spring-cloud-square,代码行数:14,代码来源:OkHttpRibbonInterceptorTests.java
示例14: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
}
示例15: restTempalte
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //导入依赖的package包/类
@Bean
@LoadBalanced
public RestTemplate restTempalte(){
return new RestTemplate();
}