Compare commits
4 Commits
094044ed73
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bfc845693 | |||
| 6b50bfaeb4 | |||
| 50f3579f6a | |||
| 47cbb100d6 |
5
pom.xml
5
pom.xml
@ -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>
|
||||
|
||||
@ -40,7 +40,7 @@ public class CustomRouteConfig {
|
||||
RouteLocatorBuilder.Builder routesBuilder = builder.routes();
|
||||
|
||||
// 定义需要路由的服务列表
|
||||
String[] serviceNames = {"sczx-user", "sczx-store", "sczx-car", "sczx-order", "sczx-sync", "sczx-singlepay"};
|
||||
String[] serviceNames = {"sczx-user", "sczx-store", "sczx-car", "sczx-order", "sczx-sync", "sczx-singlepay", "sczx-notify"};
|
||||
|
||||
// 为每个服务添加路由规则(如果服务存在)
|
||||
for (String serviceName : serviceNames) {
|
||||
|
||||
@ -59,7 +59,7 @@ public class DynamicRouteConfig implements RouteDefinitionLocator {
|
||||
List<RouteDefinition> routeDefinitions = new ArrayList<>();
|
||||
|
||||
// 定义需要路由的服务列表
|
||||
String[] serviceNames = {"sczx-user", "sczx-store", "sczx-car", "sczx-order", "sczx-sync", "sczx-singlepay"};
|
||||
String[] serviceNames = {"sczx-user", "sczx-store", "sczx-car", "sczx-order", "sczx-sync", "sczx-singlepay", "sczx-notify"};
|
||||
|
||||
// 为每个服务添加路由规则(如果服务存在)
|
||||
for (String serviceName : serviceNames) {
|
||||
|
||||
@ -44,7 +44,9 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
"/zc/sync/**",
|
||||
//支付服务都放行
|
||||
"/zc/singlepay/**",
|
||||
"/zc/notify/**",
|
||||
"/zc/order/pubOrder/**",
|
||||
"/zc/order/verify/**",
|
||||
|
||||
|
||||
// Swagger 放行
|
||||
|
||||
@ -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
|
||||
|
||||
10
src/main/resources/bootstrap.yml
Normal file
10
src/main/resources/bootstrap.yml
Normal 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 # 配置读取超时时间
|
||||
Reference in New Issue
Block a user