feat(config): 定时任务可按开关关闭,dev 配置指向测试库
本地联调时两个 @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 沿用仓库既有的测试环境取值。
This commit is contained in:
@@ -17,6 +17,7 @@ import com.gxwebsoft.think.service.ThinkOrderService;
|
|||||||
import com.gxwebsoft.think.service.ThinkSiteService;
|
import com.gxwebsoft.think.service.ThinkSiteService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -37,6 +38,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/scheduled")
|
@RequestMapping("/api/scheduled")
|
||||||
@Profile("!test")
|
@Profile("!test")
|
||||||
|
@ConditionalOnProperty(name = "config.think-scheduling-enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class SchedulingController extends BaseController {
|
public class SchedulingController extends BaseController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.gxwebsoft.think.entity.*;
|
|||||||
import com.gxwebsoft.think.service.*;
|
import com.gxwebsoft.think.service.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -36,6 +37,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Profile("!test")
|
@Profile("!test")
|
||||||
|
@ConditionalOnProperty(name = "config.think-face-access-enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class ThinkFaceAccessTask {
|
public class ThinkFaceAccessTask {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ThinkFaceAccessTask.class);
|
private static final Logger logger = LoggerFactory.getLogger(ThinkFaceAccessTask.class);
|
||||||
|
|||||||
@@ -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:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://47.121.133.163:3308/gxtyzx_ws?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
dynamic:
|
||||||
username: gxtyzx_ws
|
primary: master
|
||||||
password: 2jPKyRhw5eTLHhJJ
|
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
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
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:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.gxwebsoft: DEBUG
|
com.gxwebsoft: INFO
|
||||||
com.baomidou.mybatisplus: DEBUG
|
com.baomidou.mybatisplus: INFO
|
||||||
|
|
||||||
socketio:
|
socketio:
|
||||||
host: localhost #IP地址
|
host: localhost #IP地址
|
||||||
|
|
||||||
# 框架配置
|
# 框架配置
|
||||||
config:
|
config:
|
||||||
# 开发环境接口
|
# 生产环境接口
|
||||||
# server-url: https://gxtyzx-api2.websoft.top/api
|
server-url: https://gxtyzx-server.websoft.top/api
|
||||||
# upload-path: /www/wwwroot/gxtyzx-api/file/
|
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/
|
# 阿里云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
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ socketio:
|
|||||||
# 多环境配置
|
# 多环境配置
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
# 开发环境固定使用测试库(8.134.55.105 / Redis db5);生产/其他环境通过 SPRING_PROFILES_ACTIVE 覆盖
|
active: dev
|
||||||
active: ${SPRING_PROFILES_ACTIVE:gxtyzx-test}
|
|
||||||
# active: dev
|
|
||||||
# active: dev-local
|
# active: dev-local
|
||||||
# active: prod
|
# active: prod
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user