从nacos拉取配置

This commit is contained in:
2025-09-11 01:11:17 +08:00
parent ee7556f706
commit 47cbb100d6
3 changed files with 15 additions and 49 deletions

View File

@ -74,6 +74,11 @@
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>

View File

@ -1,55 +1,6 @@
server:
port: 8089
shutdown: graceful # 启用优雅停机
spring:
application:
name: sczx-gateway
cloud:
# gateway:
# discovery:
# locator:
# enabled: true # 开启从注册中心动态获取路由
# lower-case-service-id: true # 服务名转小写
# routes:
# - id: sczx_user
## uri: http://172.18.0.4:8081
# uri: lb://sczx_user
# predicates:
# - Path=/zc/user/**
# filters:
# - StripPrefix=2
# - id: sczx_store
# uri: lb://sczx_store
# predicates:
# - Path=/zc/store/**
# filters:
# - StripPrefix=2
nacos:
discovery:
server-addr: 115.190.8.52:8848 # Nacos 地址
group: DEFAULT_GROUP
watch-delay: 120000 # 60秒刷新一次
loadbalancer:
ribbon:
enabled: false
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
auth:
secret-key: his-is-a-very-long-and-secure-secret-key-for-jwt-signing-please-dont-use-short-keys
token-expiration: 86400000 # 24小时
#logging:
# level:
# org.springframework.cloud.gateway: DEBUG
# org.springframework.cloud.loadbalancer: DEBUG
# reactor.core.publisher: DEBUG

View File

@ -0,0 +1,10 @@
spring:
application:
name: sczx-gateway # 应用名称,对应 Nacos 配置的 dataId
cloud:
nacos:
server-addr: 115.190.8.52:8848 # Nacos 服务器地址
config:
group: DEFAULT_GROUP # 配置分组
file-extension: yaml # 配置文件格式
timeout: 5000 # 配置读取超时时间