From b366869a00bd32b0e55e3e5d5d13eb8fe0663b72 Mon Sep 17 00:00:00 2001 From: cuijiawang Date: Mon, 13 Oct 2025 16:32:54 +0800 Subject: [PATCH] gateway --- agileboot-common/pom.xml | 1 + agileboot-common/wol-common-box/pom.xml | 6 +- .../src/main/resources/base.yml | 78 +++++-------------- .../src/main/resources/common-mybatis.yml | 55 +++++++++++++ agileboot-common/wol-common-nacos/pom.xml | 38 +++++++++ .../src/main/resources/nacos.yml | 18 +++++ agileboot-common/wol-common-redis/pom.xml | 15 +++- .../redis/config/RedisConfiguration.java | 3 + .../src/main/resources/common-cache.yml | 46 +++++++++++ agileboot-system/pom.xml | 5 ++ agileboot-system/wol-gateway/pom.xml | 19 ++++- .../wol-gateway/src/main/resources/Dockerfile | 6 ++ .../src/main/resources/application.yml | 9 ++- .../src/main/resources/bootstrap.yml | 5 ++ pom.xml | 9 +++ 15 files changed, 249 insertions(+), 64 deletions(-) create mode 100644 agileboot-common/wol-common-nacos/pom.xml create mode 100644 agileboot-common/wol-common-nacos/src/main/resources/nacos.yml create mode 100644 agileboot-common/wol-common-redis/src/main/resources/common-cache.yml create mode 100644 agileboot-system/wol-gateway/src/main/resources/Dockerfile create mode 100644 agileboot-system/wol-gateway/src/main/resources/bootstrap.yml diff --git a/agileboot-common/pom.xml b/agileboot-common/pom.xml index c5f2924..2ad06b9 100644 --- a/agileboot-common/pom.xml +++ b/agileboot-common/pom.xml @@ -18,6 +18,7 @@ wol-common-redis wol-common-json wol-common-satoken + wol-common-nacos pom diff --git a/agileboot-common/wol-common-box/pom.xml b/agileboot-common/wol-common-box/pom.xml index 18348d9..60412b8 100644 --- a/agileboot-common/wol-common-box/pom.xml +++ b/agileboot-common/wol-common-box/pom.xml @@ -52,7 +52,11 @@ wol-common-satoken ${revision} - + + com.agileboot + wol-common-nacos + ${revision} + diff --git a/agileboot-common/wol-common-core/src/main/resources/base.yml b/agileboot-common/wol-common-core/src/main/resources/base.yml index 9c3764d..fb32767 100644 --- a/agileboot-common/wol-common-core/src/main/resources/base.yml +++ b/agileboot-common/wol-common-core/src/main/resources/base.yml @@ -1,63 +1,21 @@ -# 数据源配置 -spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: agileboot - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: - primary: master - strict: false - druid: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - datasource: - master: - url: jdbc:mysql://121.41.64.98:3306/agileboot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sslMode=REQUIRED - username: agileboot - password: 123456 - data: - redis: - database: 3 - host: 121.41.64.98 - port: 6379 - password: 'Wyy123123' +wol: + mysql: + maser: + url: ${MYSQL_URL:121.41.64.98:3306} + username: ${MYSQL_USERNAME:agileboot} + password: ${MYSQL_PASSWORD:123456} + redis: + database: ${REDIS_DATABASE:3} + host: ${REDIS_HOST:121.41.64.98} + port: ${REDIS_PORT:6379} + password: ${REDIS_PASSWORD:'Wyy123123'} + nacos: + server: + addr: ${NACOS_ADDR:192.168.110.27:8848} + username: ${NACOS_USERNAME:nacos} + password: ${NACOS_PASSWORD:nacos} + namespace: ${NACOS_NAMESPACE:public} + group: ${NACOS_GROUP:DEFAULT_GROUP} jasypt: encryptor: password: ${JASYPT_ENCRYPTOR_PASSWORD:} diff --git a/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml index fcc26b4..9e078ec 100644 --- a/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml +++ b/agileboot-common/wol-common-mybatis/src/main/resources/common-mybatis.yml @@ -30,3 +30,58 @@ mybatis-plus: insertStrategy: NOT_NULL updateStrategy: NOT_NULL whereStrategy: NOT_NULL + +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: agileboot + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: + primary: master + strict: false + druid: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + datasource: + master: + url: jdbc:mysql://${wol.mysql.maser.url}/agileboot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + username: ${wol.mysql.maser.username} + password: ${wol.mysql.maser.password} diff --git a/agileboot-common/wol-common-nacos/pom.xml b/agileboot-common/wol-common-nacos/pom.xml new file mode 100644 index 0000000..358b806 --- /dev/null +++ b/agileboot-common/wol-common-nacos/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + + com.agileboot + agileboot-common + 1.0.0 + + wol-common-nacos + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + diff --git a/agileboot-common/wol-common-nacos/src/main/resources/nacos.yml b/agileboot-common/wol-common-nacos/src/main/resources/nacos.yml new file mode 100644 index 0000000..ad19821 --- /dev/null +++ b/agileboot-common/wol-common-nacos/src/main/resources/nacos.yml @@ -0,0 +1,18 @@ +spring: + cloud: + nacos: + discovery: + server-addr: ${wol.nacos.server.addr} + username: ${wol.nacos.server.username} + password: ${wol.nacos.server.password} + group: ${wol.nacos.server.group} + namespace: ${wol.nacos.server.namespace} + config: + server-addr: ${wol.nacos.server.addr} + group: ${wol.nacos.server.group} + namespace: ${wol.nacos.server.namespace} + file-extension: yaml + refresh-enabled: true # 是否开启动态刷新 + name: ${spring.application.name} + username: ${wol.nacos.server.username} + password: ${wol.nacos.server.password} diff --git a/agileboot-common/wol-common-redis/pom.xml b/agileboot-common/wol-common-redis/pom.xml index 002130f..79afe40 100644 --- a/agileboot-common/wol-common-redis/pom.xml +++ b/agileboot-common/wol-common-redis/pom.xml @@ -40,6 +40,19 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/agileboot-common/wol-common-redis/src/main/java/com/agileboot/common/redis/config/RedisConfiguration.java b/agileboot-common/wol-common-redis/src/main/java/com/agileboot/common/redis/config/RedisConfiguration.java index d1e020a..1eacf01 100644 --- a/agileboot-common/wol-common-redis/src/main/java/com/agileboot/common/redis/config/RedisConfiguration.java +++ b/agileboot-common/wol-common-redis/src/main/java/com/agileboot/common/redis/config/RedisConfiguration.java @@ -1,5 +1,6 @@ package com.agileboot.common.redis.config; +import com.agileboot.common.core.factory.YmlPropertySourceFactory; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.PropertyAccessor; @@ -12,6 +13,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.PropertySource; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; @@ -19,6 +21,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; @Slf4j @AutoConfiguration +@PropertySource(value = "classpath:common-cache.yml", factory = YmlPropertySourceFactory.class) public class RedisConfiguration { @Bean diff --git a/agileboot-common/wol-common-redis/src/main/resources/common-cache.yml b/agileboot-common/wol-common-redis/src/main/resources/common-cache.yml new file mode 100644 index 0000000..7c6706e --- /dev/null +++ b/agileboot-common/wol-common-redis/src/main/resources/common-cache.yml @@ -0,0 +1,46 @@ +spring: + data: + redis: + database: ${wol.redis.database} + host: ${wol.redis.host} + port: ${wol.redis.port} + password: ${wol.redis.password} + redis: + redisson: + config: | + singleServerConfig: + idleConnectionTimeout: 10000 + connectTimeout: 10000 + timeout: 3000 + retryAttempts: 3 + retryInterval: 1500 + password: ${wol.redis.password} + subscriptionsPerConnection: 5 + clientName: null + address: "redis://${wol.redis.host}:${wol.redis.port}" + subscriptionConnectionMinimumIdleSize: 1 + subscriptionConnectionPoolSize: 50 + connectionMinimumIdleSize: 24 + connectionPoolSize: 64 + database: 0 + dnsMonitoringInterval: 5000 + threads: 16 + nettyThreads: 32 + codec: ! {} + transportMode: "NIO" +jetcache: + statIntervalMinutes: 1 + areaInCacheName: false + local: + default: + type: caffeine + keyConvertor: fastjson2 + remote: + default: + type: redisson + keyConvertor: fastjson2 + broadcastChannel: ${spring.application.name} + keyPrefix: ${spring.application.name} + valueEncoder: java + valueDecoder: java + defaultExpireInMillis: 5000 diff --git a/agileboot-system/pom.xml b/agileboot-system/pom.xml index 529229c..048019f 100644 --- a/agileboot-system/pom.xml +++ b/agileboot-system/pom.xml @@ -22,6 +22,11 @@ agileboot-system-base 1.0.0 + + com.agileboot + wol-common-nacos + 1.0.0 + diff --git a/agileboot-system/wol-gateway/pom.xml b/agileboot-system/wol-gateway/pom.xml index e8282b3..439c8e7 100644 --- a/agileboot-system/wol-gateway/pom.xml +++ b/agileboot-system/wol-gateway/pom.xml @@ -16,6 +16,12 @@ + + + com.agileboot + wol-common-nacos + + com.agileboot wol-common-satoken @@ -31,16 +37,27 @@ cn.dev33 sa-token-reactor-spring-boot3-starter ${satoken.version} + + + org.springframework.boot + spring-boot-starter-web + + org.springframework.cloud spring-cloud-starter-gateway - org.springframework.cloud spring-cloud-starter-loadbalancer + + + org.springframework.boot + spring-boot-starter + + diff --git a/agileboot-system/wol-gateway/src/main/resources/Dockerfile b/agileboot-system/wol-gateway/src/main/resources/Dockerfile new file mode 100644 index 0000000..03680f6 --- /dev/null +++ b/agileboot-system/wol-gateway/src/main/resources/Dockerfile @@ -0,0 +1,6 @@ +FROM amazoncorretto:17 +MAINTAINER 1293433164@qq.com +ADD target/wol-gateway-1.0.0.jar /gateway.jar +EXPOSE 18080 +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone +ENTRYPOINT ["java", "-jar", "/gateway.jar"] diff --git a/agileboot-system/wol-gateway/src/main/resources/application.yml b/agileboot-system/wol-gateway/src/main/resources/application.yml index fe37d2d..673edfc 100644 --- a/agileboot-system/wol-gateway/src/main/resources/application.yml +++ b/agileboot-system/wol-gateway/src/main/resources/application.yml @@ -8,4 +8,11 @@ spring: application: name: @application.name@ config: - import: classpath:base.yml + import: classpath:base.yml,classpath:nacos.yml + +logging: + level: + root: INFO + org.springframework.cloud.gateway: DEBUG + com.alibaba.nacos: DEBUG + org.springframework.boot: DEBUG diff --git a/agileboot-system/wol-gateway/src/main/resources/bootstrap.yml b/agileboot-system/wol-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..c74ed41 --- /dev/null +++ b/agileboot-system/wol-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,5 @@ +spring: + application: + name: @application.name@ + config: + import: classpath:base.yml,classpath:nacos.yml diff --git a/pom.xml b/pom.xml index 2033c43..0e4e458 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ 17 3.4.7 2024.0.0 + 2023.0.3.3 3.5.16 3.5.12 4.3.1 @@ -72,6 +73,14 @@ pom import + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + org.springframework.boot