From c5d36a8200bbd8a8b50a5945f34ca93281711cd8 Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 27 Sep 2019 20:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Deureka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/files/10112_使用eureka.md | 8 +++++++- .../src/main/resources/application-dev.properties | 10 ---------- sop-example/sop-book/sop-book-web/pom.xml | 8 +------- .../src/main/resources/application-dev.properties | 5 +---- sop-example/sop-story/sop-story-web/pom.xml | 8 +------- .../src/main/resources/application-dev.properties | 5 +---- sop-gateway/pom.xml | 12 +++--------- .../src/main/resources/application-dev.properties | 7 ++----- 8 files changed, 16 insertions(+), 47 deletions(-) diff --git a/doc/docs/files/10112_使用eureka.md b/doc/docs/files/10112_使用eureka.md index cd06ae54..d239eb6e 100644 --- a/doc/docs/files/10112_使用eureka.md +++ b/doc/docs/files/10112_使用eureka.md @@ -4,7 +4,9 @@ - 打开`/sop-gateway/pom.xml` -添加依赖: +注释nacos相关依赖 + +添加eureka依赖: ```xml @@ -39,6 +41,10 @@ eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ 打开`application-dev.properties`,新增配置 ```properties +# 网关地址,多个用逗号隔开 +# 在不使用nacos时有用,使用nacos时注释掉 +gateway.host=127.0.0.1:8081 + # eureka注册中心 eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ # 如果使用eureka,填eureka,使用nacos,填eureka diff --git a/sop-admin/sop-admin-server/src/main/resources/application-dev.properties b/sop-admin/sop-admin-server/src/main/resources/application-dev.properties index e33fd59c..62b798f0 100644 --- a/sop-admin/sop-admin-server/src/main/resources/application-dev.properties +++ b/sop-admin/sop-admin-server/src/main/resources/application-dev.properties @@ -9,18 +9,8 @@ mysql.password=root # nacos注册中心地址 nacos.url=127.0.0.1:8848 - -# 网关地址,多个用逗号隔开 -# 在不使用nacos时有用,使用nacos时注释掉 -gateway.host=127.0.0.1:8081 # ------- 需要改的配置end ------- -# eureka注册中心 -eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ -# 如果使用eureka,填eureka,使用nacos,填eureka -registry.name=eureka - - # token过期时间,分钟 admin.access-token.timeout-minutes=30 # 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式 diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index 367daa30..47cf5e79 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -45,7 +45,7 @@ org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery @@ -56,14 +56,8 @@ nacos-client ${nacos-client.version} - --> - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - org.springframework.cloud spring-cloud-starter-openfeign diff --git a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.properties b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.properties index 4217726b..05644cb7 100644 --- a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.properties +++ b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.properties @@ -1,11 +1,8 @@ server.port=3333 spring.application.name=book-service -# eureka注册中心 -eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ - # nacos注册中心 -#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 +spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 # consumer不需要检查provider是否启动 dubbo.consumer.check=false diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index 976ef3bc..8e489cb5 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -39,7 +39,7 @@ org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery @@ -50,14 +50,8 @@ nacos-client ${nacos-client.version} - --> - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - org.springframework.cloud spring-cloud-starter-openfeign diff --git a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties index ff51c42c..f0150321 100644 --- a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties +++ b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties @@ -1,11 +1,8 @@ server.port=2222 spring.application.name=story-service -# eureka注册中心 -eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ - # nacos注册中心 -#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 +spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 # dubbo配置 dubbo.protocol.name=dubbo diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index 84443c06..f17a0ce5 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -59,15 +59,10 @@ spring-cloud-starter-netflix-zuul - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery @@ -78,19 +73,18 @@ nacos-client ${nacos-client.version} - --> com.alibaba.boot nacos-config-spring-boot-starter ${nacos-spring-boot-starter.version} - --> + diff --git a/sop-gateway/src/main/resources/application-dev.properties b/sop-gateway/src/main/resources/application-dev.properties index 9b84c486..00eb54a5 100644 --- a/sop-gateway/src/main/resources/application-dev.properties +++ b/sop-gateway/src/main/resources/application-dev.properties @@ -18,9 +18,6 @@ zipkin.url=http://127.0.0.1:9411/ pre.domain=localhost # ------- 需要改的配置end ------- -# eureka注册中心 -eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/ - # 入口地址,不用改,默认是/zuul zuul.servlet-path=/api # 禁用默认的过滤器,不能删,不用改 @@ -40,8 +37,8 @@ ribbon.ReadTimeout=2000 ribbon.OkToRetryOnAllOperations=false # nacos cloud配置 -#spring.cloud.nacos.discovery.server-addr=${nacos.url} -#nacos.config.server-addr=${nacos.url} +spring.cloud.nacos.discovery.server-addr=${nacos.url} +nacos.config.server-addr=${nacos.url} spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://${mysql.host}/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai