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

update nacos version to 0.2.1-RC and format code

This commit is contained in:
flystar32
2018-09-20 11:31:50 +08:00
parent 2d277e42c1
commit e4d9f98313
12 changed files with 114 additions and 109 deletions

View File

@@ -20,22 +20,19 @@ import org.springframework.web.client.RestTemplate;
@EnableFeignClients
public class ConsumerApplication {
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
@FeignClient(name = "service-provider")
public interface EchoService {
@RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
String echo(@PathVariable("str") String str);
}
@FeignClient(name = "service-provider")
public interface EchoService {
@RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
String echo(@PathVariable("str") String str);
}
}

View File

@@ -15,31 +15,32 @@ import org.springframework.web.client.RestTemplate;
@RestController
public class TestController {
@Autowired
private RestTemplate restTemplate;
@Autowired
private EchoService echoService;
@Autowired
private RestTemplate restTemplate;
@Autowired
private EchoService echoService;
@Autowired
private DiscoveryClient discoveryClient;
@Autowired
private DiscoveryClient discoveryClient;
@RequestMapping(value = "/echo-rest/{str}", method = RequestMethod.GET)
public String rest(@PathVariable String str) {
return restTemplate.getForObject("http://service-provider/echo/" + str,
String.class);
}
@RequestMapping(value = "/echo-rest/{str}", method = RequestMethod.GET)
public String rest(@PathVariable String str) {
return restTemplate.getForObject("http://service-provider/echo/" + str, String.class);
}
@RequestMapping(value = "/echo-feign/{str}", method = RequestMethod.GET)
public String feign(@PathVariable String str) {
return echoService.echo(str);
}
@RequestMapping(value = "/echo-feign/{str}", method = RequestMethod.GET)
public String feign(@PathVariable String str) {
return echoService.echo(str);
}
@RequestMapping(value = "/services/{service}", method = RequestMethod.GET)
public Object client(@PathVariable String service) {
return discoveryClient.getInstances(service);
}
@RequestMapping(value="/services/{service}",method = RequestMethod.GET)
public Object client(@PathVariable String service){
return discoveryClient.getInstances(service);
}
@RequestMapping(value="/services",method = RequestMethod.GET)
public Object services(){
return discoveryClient.getServices();
}
@RequestMapping(value = "/services", method = RequestMethod.GET)
public Object services() {
return discoveryClient.getServices();
}
}

View File

@@ -1,4 +1,4 @@
spring.application.name=service-consumer
server.port=18083
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848

View File

@@ -1,4 +1,4 @@
server.port=18082
spring.application.name=service-provider
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
management.endpoints.web.exposure.include=*