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:
@@ -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>
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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
|
@@ -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,
|
||||
|
@@ -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>
|
||||
|
@@ -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
|
Reference in New Issue
Block a user