This commit is contained in:
tanghc
2019-07-01 17:49:45 +08:00
parent 6fc49f2699
commit 4bc76f497d
8 changed files with 39 additions and 33 deletions

View File

@@ -37,7 +37,7 @@ registry:
eureka-server-addr: http://localhost:1111/eureka/
nacos-server-addr: 127.0.0.1:8848
# 使用哪个配置中心使用eureka填eureka使用nacos填nacos
name: nacos
name: eureka
# 根据实际情况改

View File

@@ -50,6 +50,9 @@ public enum EurekaUri {
}
public Request getRequest(String url, String... args) {
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
String requestUrl = url + getUri(args);
Request request = this.getBuilder()
.url(requestUrl)

View File

@@ -39,22 +39,23 @@
<!-- 注册中心【只能用一个,不用的注释掉】 -->
<!-- 使用eureka注册中心
<!-- 使用eureka注册中心 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
-->
<!-- 使用nacos注册中心
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>0.2.2.RELEASE</version>
</dependency>
-->
<!-- 注册中心end -->

View File

@@ -11,15 +11,15 @@ spring:
connect-string: localhost:2181
# nacos注册中心和eureka只能用一个
nacos:
discovery:
server-addr: 127.0.0.1:8848
# nacos:
# discovery:
# server-addr: 127.0.0.1:8848
# eureka注册中心如果使用nacos注册中心这里要注释掉
#eureka:
# client:
# serviceUrl:
# defaultZone: http://localhost:1111/eureka/
eureka:
client:
serviceUrl:
defaultZone: http://localhost:1111/eureka/
# dubbo consumer
demo:

View File

@@ -33,22 +33,23 @@
</dependency>
<!-- 注册中心【只能用一个,不用的注释掉】 -->
<!-- 使用eureka注册中心
<!-- 使用eureka注册中心 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
-->
<!-- 使用nacos注册中心
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>0.2.2.RELEASE</version>
</dependency>
-->
<!-- 注册中心end -->
<dependency>

View File

@@ -11,15 +11,15 @@ spring:
connect-string: localhost:2181
# nacos注册中心和eureka只能用一个
nacos:
discovery:
server-addr: 127.0.0.1:8848
# nacos:
# discovery:
# server-addr: 127.0.0.1:8848
# eureka注册中心如果使用nacos注册中心这里要注释掉
#eureka:
# client:
# serviceUrl:
# defaultZone: http://localhost:1111/eureka/
eureka:
client:
serviceUrl:
defaultZone: http://localhost:1111/eureka/
# dubbo provider
dubbo:

View File

@@ -66,22 +66,23 @@
</dependency>
<!-- 注册中心【只能用一个,不用的注释掉】 -->
<!-- 使用eureka注册中心
<!-- 使用eureka注册中心 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
-->
<!-- 使用nacos注册中心
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>0.2.2.RELEASE</version>
</dependency>
-->
<!-- 注册中心end -->
<!-- test -->

View File

@@ -19,6 +19,12 @@ ribbon:
# 请谨慎设置因为post请求大多都是写入请求如果要支持重试确保服务的幂等性
OkToRetryOnAllOperations: false
# eureka注册中心如果使用nacos注册中心这里要注释掉
eureka:
client:
serviceUrl:
defaultZone: http://localhost:1111/eureka/
spring:
application:
name: api-gateway
@@ -35,15 +41,9 @@ spring:
enabled: true
# nacos注册中心和eureka只能用一个
nacos:
discovery:
server-addr: 127.0.0.1:8848
# eureka注册中心如果使用nacos注册中心这里要注释掉
#eureka:
# client:
# serviceUrl:
# defaultZone: http://localhost:1111/eureka/
# nacos:
# discovery:
# server-addr: 127.0.0.1:8848
# 数据源,根据实际情况修改
datasource: