mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
适配eureka
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
- 打开`/sop-gateway/pom.xml`
|
- 打开`/sop-gateway/pom.xml`
|
||||||
|
|
||||||
添加依赖:
|
注释nacos相关依赖
|
||||||
|
|
||||||
|
添加eureka依赖:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -39,6 +41,10 @@ eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
|||||||
打开`application-dev.properties`,新增配置
|
打开`application-dev.properties`,新增配置
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
|
# 网关地址,多个用逗号隔开
|
||||||
|
# 在不使用nacos时有用,使用nacos时注释掉
|
||||||
|
gateway.host=127.0.0.1:8081
|
||||||
|
|
||||||
# eureka注册中心
|
# eureka注册中心
|
||||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
||||||
# 如果使用eureka,填eureka,使用nacos,填eureka
|
# 如果使用eureka,填eureka,使用nacos,填eureka
|
||||||
|
@@ -9,18 +9,8 @@ mysql.password=root
|
|||||||
|
|
||||||
# nacos注册中心地址
|
# nacos注册中心地址
|
||||||
nacos.url=127.0.0.1:8848
|
nacos.url=127.0.0.1:8848
|
||||||
|
|
||||||
# 网关地址,多个用逗号隔开
|
|
||||||
# 在不使用nacos时有用,使用nacos时注释掉
|
|
||||||
gateway.host=127.0.0.1:8081
|
|
||||||
# ------- 需要改的配置end -------
|
# ------- 需要改的配置end -------
|
||||||
|
|
||||||
# eureka注册中心
|
|
||||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
|
||||||
# 如果使用eureka,填eureka,使用nacos,填eureka
|
|
||||||
registry.name=eureka
|
|
||||||
|
|
||||||
|
|
||||||
# token过期时间,分钟
|
# token过期时间,分钟
|
||||||
admin.access-token.timeout-minutes=30
|
admin.access-token.timeout-minutes=30
|
||||||
# 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式
|
# 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
<!-- 使用nacos注册中心
|
<!-- 使用nacos注册中心
|
||||||
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
版本 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
|
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
@@ -56,14 +56,8 @@
|
|||||||
<artifactId>nacos-client</artifactId>
|
<artifactId>nacos-client</artifactId>
|
||||||
<version>${nacos-client.version}</version>
|
<version>${nacos-client.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
<!-- 注册中心end -->
|
<!-- 注册中心end -->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
server.port=3333
|
server.port=3333
|
||||||
spring.application.name=book-service
|
spring.application.name=book-service
|
||||||
|
|
||||||
# eureka注册中心
|
|
||||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
|
||||||
|
|
||||||
# nacos注册中心
|
# 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是否启动
|
# consumer不需要检查provider是否启动
|
||||||
dubbo.consumer.check=false
|
dubbo.consumer.check=false
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
<!-- 使用nacos注册中心
|
<!-- 使用nacos注册中心
|
||||||
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
版本 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
|
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
@@ -50,14 +50,8 @@
|
|||||||
<artifactId>nacos-client</artifactId>
|
<artifactId>nacos-client</artifactId>
|
||||||
<version>${nacos-client.version}</version>
|
<version>${nacos-client.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
<!-- 注册中心end -->
|
<!-- 注册中心end -->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
server.port=2222
|
server.port=2222
|
||||||
spring.application.name=story-service
|
spring.application.name=story-service
|
||||||
|
|
||||||
# eureka注册中心
|
|
||||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
|
||||||
|
|
||||||
# nacos注册中心
|
# 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配置
|
||||||
dubbo.protocol.name=dubbo
|
dubbo.protocol.name=dubbo
|
||||||
|
@@ -59,15 +59,10 @@
|
|||||||
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 使用nacos注册中心
|
<!-- 使用nacos注册中心
|
||||||
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
版本 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
|
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
@@ -78,19 +73,18 @@
|
|||||||
<artifactId>nacos-client</artifactId>
|
<artifactId>nacos-client</artifactId>
|
||||||
<version>${nacos-client.version}</version>
|
<version>${nacos-client.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
<!-- 注册中心end -->
|
<!-- 注册中心end -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
这里依赖springboot版本,非cloud版本。
|
这里依赖springboot版本,非cloud版本。
|
||||||
如果依赖了spring-cloud-starter-alibaba-nacos-config,需要额外配置一个bootstrap.properties
|
如果依赖了spring-cloud-starter-alibaba-nacos-config,需要额外配置一个bootstrap.properties
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.boot</groupId>
|
<groupId>com.alibaba.boot</groupId>
|
||||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||||
<version>${nacos-spring-boot-starter.version}</version>
|
<version>${nacos-spring-boot-starter.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- test -->
|
<!-- test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@@ -18,9 +18,6 @@ zipkin.url=http://127.0.0.1:9411/
|
|||||||
pre.domain=localhost
|
pre.domain=localhost
|
||||||
# ------- 需要改的配置end -------
|
# ------- 需要改的配置end -------
|
||||||
|
|
||||||
# eureka注册中心
|
|
||||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
|
||||||
|
|
||||||
# 入口地址,不用改,默认是/zuul
|
# 入口地址,不用改,默认是/zuul
|
||||||
zuul.servlet-path=/api
|
zuul.servlet-path=/api
|
||||||
# 禁用默认的过滤器,不能删,不用改
|
# 禁用默认的过滤器,不能删,不用改
|
||||||
@@ -40,8 +37,8 @@ ribbon.ReadTimeout=2000
|
|||||||
ribbon.OkToRetryOnAllOperations=false
|
ribbon.OkToRetryOnAllOperations=false
|
||||||
|
|
||||||
# nacos cloud配置
|
# nacos cloud配置
|
||||||
#spring.cloud.nacos.discovery.server-addr=${nacos.url}
|
spring.cloud.nacos.discovery.server-addr=${nacos.url}
|
||||||
#nacos.config.server-addr=${nacos.url}
|
nacos.config.server-addr=${nacos.url}
|
||||||
|
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
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
|
spring.datasource.url=jdbc:mysql://${mysql.host}/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
|
Reference in New Issue
Block a user