From c8ff29d864dbb8ef239310161ada6553f9a28be4 Mon Sep 17 00:00:00 2001 From: weicw <594098497@qq.com> Date: Sat, 31 Oct 2026 13:22:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=8F=AF=E6=8C=89=E5=BC=80=E5=85=B3=E5=85=B3=E9=97=AD?= =?UTF-8?q?=EF=BC=8Cdev=20=E9=85=8D=E7=BD=AE=E6=8C=87=E5=90=91=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 本地联调时两个 @Profile("!test") 的任务会干扰共享测试库: - SchedulingController 每秒触发,回写订单 - ThinkFaceAccessTask 需连闸机 47.121.133.163:18098,本机不可达 给两者加 @ConditionalOnProperty(matchIfMissing = true,生产行为不变), 默认开启,可在配置里关掉。 application-dev.yml 改为测试环境配置(8.134.55.105:13306 / 本地 Redis db5),并把两个任务开关置为 false;application.yml 默认激活 profile 改为 dev。OSS 与 server-url 沿用仓库既有的测试环境取值。 --- .../controller/SchedulingController.java | 2 + .../think/task/ThinkFaceAccessTask.java | 2 + src/main/resources/application-dev.yml | 59 ++++++++++++++----- src/main/resources/application.yml | 4 +- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gxwebsoft/think/controller/SchedulingController.java b/src/main/java/com/gxwebsoft/think/controller/SchedulingController.java index bd45ea6..79cbd8d 100644 --- a/src/main/java/com/gxwebsoft/think/controller/SchedulingController.java +++ b/src/main/java/com/gxwebsoft/think/controller/SchedulingController.java @@ -17,6 +17,7 @@ import com.gxwebsoft.think.service.ThinkOrderService; import com.gxwebsoft.think.service.ThinkSiteService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.RequestMapping; @@ -37,6 +38,7 @@ import java.util.concurrent.TimeUnit; @RestController @RequestMapping("/api/scheduled") @Profile("!test") +@ConditionalOnProperty(name = "config.think-scheduling-enabled", havingValue = "true", matchIfMissing = true) public class SchedulingController extends BaseController { @Resource diff --git a/src/main/java/com/gxwebsoft/think/task/ThinkFaceAccessTask.java b/src/main/java/com/gxwebsoft/think/task/ThinkFaceAccessTask.java index fb2ede4..fa69aee 100644 --- a/src/main/java/com/gxwebsoft/think/task/ThinkFaceAccessTask.java +++ b/src/main/java/com/gxwebsoft/think/task/ThinkFaceAccessTask.java @@ -9,6 +9,7 @@ import com.gxwebsoft.think.entity.*; import com.gxwebsoft.think.service.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -36,6 +37,7 @@ import java.util.stream.Collectors; */ @Component @Profile("!test") +@ConditionalOnProperty(name = "config.think-face-access-enabled", havingValue = "true", matchIfMissing = true) public class ThinkFaceAccessTask { private static final Logger logger = LoggerFactory.getLogger(ThinkFaceAccessTask.class); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 12610e2..cb288ca 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,27 +1,58 @@ -# 开发环境配置 +# 测试环境配置(8.134.55.105:13306 / 本地 Redis database 5) +# +# application.yml 已默认激活 dev,直接启动即可: +# sh mvnw spring-boot:run +# 或: +# java -jar target/com-gxwebsoft-server-1.5.2.jar -# 数据源配置 spring: datasource: - url: jdbc:mysql://47.121.133.163:3308/gxtyzx_ws?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 - username: gxtyzx_ws - password: 2jPKyRhw5eTLHhJJ - driver-class-name: com.mysql.cj.jdbc.Driver - type: com.alibaba.druid.pool.DruidDataSource + dynamic: + primary: master + strict: false + datasource: + master: + url: jdbc:mysql://8.134.55.105:13306/db_gxtyzx?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 + username: db_gxtyzx + password: ekXdi5iJMjHKaw3K + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + server: + url: jdbc:mysql://47.121.133.163:3308/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true + username: gxwebsoft_core + password: jdj7HYEdYHnYEFBy + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 5 + host: 127.0.0.1 + port: 6379 + password: # 日志配置 logging: level: - com.gxwebsoft: DEBUG - com.baomidou.mybatisplus: DEBUG + com.gxwebsoft: INFO + com.baomidou.mybatisplus: INFO socketio: host: localhost #IP地址 # 框架配置 config: - # 开发环境接口 -# server-url: https://gxtyzx-api2.websoft.top/api -# upload-path: /www/wwwroot/gxtyzx-api/file/ - server-url: http://127.0.0.1:9099/api - upload-path: /Users/liangxin/Project/JAVA/gxtyzx-java/file/ + # 生产环境接口 + server-url: https://gxtyzx-server.websoft.top/api + upload-path: /www/wwwroot/gxtyzx-api/file/ + + # 阿里云OSS云存储 + endpoint: https://oss-cn-shenzhen.aliyuncs.com + accessKeyId: LTAI4GKGZ9Z2Z8JZ77c3GNZP + accessKeySecret: BiDkpS7UXj72HWwDWaFZxiXjNFBNCM + bucketName: oss-gxwebsoft + bucketDomain: https://oss.wsdns.cn + aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com + + # 本地联调关闭旧 ThinkPHP 定时任务(SchedulingController 每秒触发,会回写共享测试库订单) + think-scheduling-enabled: false + # 本地联调关闭人脸闸机同步(闸机服务 47.121.133.163:18098 从本机不可达) + think-face-access-enabled: false diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 585021b..a3da66c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,9 +7,7 @@ socketio: # 多环境配置 spring: profiles: - # 开发环境固定使用测试库(8.134.55.105 / Redis db5);生产/其他环境通过 SPRING_PROFILES_ACTIVE 覆盖 - active: ${SPRING_PROFILES_ACTIVE:gxtyzx-test} -# active: dev + active: dev # active: dev-local # active: prod