1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

pass code check

This commit is contained in:
fangjian0423 2020-01-14 16:54:01 +08:00
parent ddceb5f312
commit 00d449ba23
10 changed files with 59 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 the original author or authors. * Copyright 2013-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,8 +62,13 @@ public class ConsumerSCLBApplication {
return new RestTemplate(); return new RestTemplate();
} }
public static void main(String[] args) {
SpringApplication.run(ConsumerSCLBApplication.class, args);
}
@Configuration @Configuration
@LoadBalancerClient(value = "service-provider", configuration = MyLoadBalancerConfiguration.class) @LoadBalancerClient(value = "service-provider",
configuration = MyLoadBalancerConfiguration.class)
class MySCLBConfiguration { class MySCLBConfiguration {
} }
@ -79,7 +84,7 @@ public class ConsumerSCLBApplication {
private final Random random; private final Random random;
public RandomLoadBalancer( RandomLoadBalancer(
ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider,
String serviceId) { String serviceId) {
this.serviceInstanceListSupplierProvider = serviceInstanceListSupplierProvider; this.serviceInstanceListSupplierProvider = serviceInstanceListSupplierProvider;
@ -104,6 +109,7 @@ public class ConsumerSCLBApplication {
return new DefaultResponse(instance); return new DefaultResponse(instance);
} }
} }
@FeignClient(name = "service-provider") @FeignClient(name = "service-provider")
@ -126,6 +132,7 @@ public class ConsumerSCLBApplication {
@RestController @RestController
class TestController { class TestController {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@ -145,8 +152,4 @@ public class ConsumerSCLBApplication {
} }
public static void main(String[] args) {
SpringApplication.run(ConsumerSCLBApplication.class, args);
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 the original author or authors. * Copyright 2013-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 the original author or authors. * Copyright 2013-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,8 +42,13 @@ public class ConsumerReactiveApplication {
return WebClient.builder(); return WebClient.builder();
} }
public static void main(String[] args) {
SpringApplication.run(ConsumerReactiveApplication.class, args);
}
@RestController @RestController
class MyController { class MyController {
@Autowired @Autowired
private ReactiveDiscoveryClient reactiveDiscoveryClient; private ReactiveDiscoveryClient reactiveDiscoveryClient;
@ -63,10 +68,7 @@ public class ConsumerReactiveApplication {
.uri("http://service-provider/echo/" + name).retrieve() .uri("http://service-provider/echo/" + name).retrieve()
.bodyToMono(String.class); .bodyToMono(String.class);
} }
}
public static void main(String[] args) {
SpringApplication.run(ConsumerReactiveApplication.class, args);
} }
} }

View File

@ -38,7 +38,8 @@ import org.springframework.web.client.RestTemplate;
public class ServiceApplication { public class ServiceApplication {
@Bean @Bean
@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = ExceptionUtil.class) @SentinelRestTemplate(blockHandler = "handleException",
blockHandlerClass = ExceptionUtil.class)
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }

View File

@ -64,7 +64,8 @@ public class NacosConfigAutoConfiguration {
public NacosContextRefresher nacosContextRefresher( public NacosContextRefresher nacosContextRefresher(
NacosConfigManager nacosConfigManager, NacosConfigManager nacosConfigManager,
NacosRefreshHistory nacosRefreshHistory) { NacosRefreshHistory nacosRefreshHistory) {
// Consider that it is not necessary to be compatible with the previous configuration // Consider that it is not necessary to be compatible with the previous
// configuration
// and use the new configuration if necessary. // and use the new configuration if necessary.
return new NacosContextRefresher(nacosConfigManager, nacosRefreshHistory); return new NacosContextRefresher(nacosConfigManager, nacosRefreshHistory);
} }

View File

@ -35,26 +35,23 @@ import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
/** /**
* @author liujunjie * @author liujunjie
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = @SpringBootTest(classes = NacosRibbonClientPropertyOverrideTests.TestConfiguration.class,
NacosRibbonClientPropertyOverrideTests.TestConfiguration.class, properties = { "spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
properties = {"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
"spring.cloud.nacos.discovery.port=18080", "spring.cloud.nacos.discovery.port=18080",
"spring.cloud.nacos.discovery.service=remoteApp", "spring.cloud.nacos.discovery.service=remoteApp",
"localApp.ribbon.NIWSServerListClassName=" "localApp.ribbon.NIWSServerListClassName="
+ "com.netflix.loadbalancer.ConfigurationBasedServerList", + "com.netflix.loadbalancer.ConfigurationBasedServerList",
"localApp.ribbon.listOfServers=127.0.0.1:19090", "localApp.ribbon.listOfServers=127.0.0.1:19090",
"localApp.ribbon.ServerListRefreshInterval=15000"}) "localApp.ribbon.ServerListRefreshInterval=15000" })
public class NacosRibbonClientPropertyOverrideTests { public class NacosRibbonClientPropertyOverrideTests {
@Autowired @Autowired
private SpringClientFactory factory; private SpringClientFactory factory;
@Test @Test
public void serverListOverridesToTest() { public void serverListOverridesToTest() {
ConfigurationBasedServerList.class ConfigurationBasedServerList.class
@ -63,8 +60,7 @@ public class NacosRibbonClientPropertyOverrideTests {
@Test @Test
public void serverListRemoteTest() { public void serverListRemoteTest() {
NacosServerList.class NacosServerList.class.cast(getLoadBalancer("remoteApp").getServerListImpl());
.cast(getLoadBalancer("remoteApp").getServerListImpl());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -75,10 +71,11 @@ public class NacosRibbonClientPropertyOverrideTests {
@Configuration @Configuration
@RibbonClients @RibbonClients
@EnableAutoConfiguration @EnableAutoConfiguration
@ImportAutoConfiguration({UtilAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, @ImportAutoConfiguration({ UtilAutoConfiguration.class,
ArchaiusAutoConfiguration.class, RibbonNacosAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ArchaiusAutoConfiguration.class,
NacosDiscoveryClientConfiguration.class}) RibbonNacosAutoConfiguration.class, NacosDiscoveryClientConfiguration.class })
protected static class TestConfiguration { protected static class TestConfiguration {
} }
} }

View File

@ -42,7 +42,8 @@ public final class RocketMQBinderUtils {
result.setNameServer(rocketBinderConfigurationProperties.getNameServer()); result.setNameServer(rocketBinderConfigurationProperties.getNameServer());
} }
else { else {
result.setNameServer(Arrays.asList(rocketMQProperties.getNameServer().split(";"))); result.setNameServer(
Arrays.asList(rocketMQProperties.getNameServer().split(";")));
} }
if (rocketMQProperties.getProducer() == null if (rocketMQProperties.getProducer() == null
|| StringUtils.isEmpty(rocketMQProperties.getProducer().getAccessKey())) { || StringUtils.isEmpty(rocketMQProperties.getProducer().getAccessKey())) {