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

nacos discovery support register service to ANS

This commit is contained in:
得少
2019-02-18 12:49:31 +08:00
parent 3ac295747b
commit 92d559c7fb
13 changed files with 156 additions and 24 deletions

View File

@@ -45,6 +45,10 @@
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alicloud-context</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -32,7 +32,7 @@ public class ConsumerApplication {
SpringApplication.run(ConsumerApplication.class, args);
}
@FeignClient(name = "service-provider", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)
@FeignClient(name = "service-provider-1X", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)
public interface EchoService {
@RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
String echo(@PathVariable("str") String str);

View File

@@ -3,11 +3,7 @@ package org.springframework.cloud.alibaba.cloud.examples;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.alibaba.cloud.examples.ConsumerApplication.EchoService;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
/**
@@ -26,7 +22,7 @@ public class TestController {
@RequestMapping(value = "/echo-rest/{str}", method = RequestMethod.GET)
public String rest(@PathVariable String str) {
return restTemplate.getForObject("http://service-provider/echo/" + str,
return restTemplate.getForObject("http://service-provider-1X/echo/" + str,
String.class);
}

View File

@@ -1,12 +1,9 @@
spring.application.name=service-consumer
spring.application.name=service-consumer-1X
server.port=18083
management.security.enabled=false
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
feign.sentinel.enabled=true
spring.cloud.sentinel.transport.dashboard=localhost:8080
spring.cloud.sentinel.eager=true
spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
spring.cloud.sentinel.datasource.ds1.file.data-type=json

View File

@@ -1,6 +1,6 @@
[
{
"resource": "GET:http://service-provider/echo/{str}",
"resource": "GET:http://service-provider-1X/echo/{str}",
"controlBehavior": 0,
"count": 1,
"grade": 1,

View File

@@ -30,6 +30,10 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alicloud-context</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -1,4 +1,4 @@
server.port=18082
spring.application.name=service-provider
spring.application.name=service-provider-1X
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
management.security.enabled=false