
后端部署
2025/6/18大约 7 分钟
一、创建数据库
1.Mysql数据库
创建qdata数据库,字符集使用utf8mb4,导入项目中的 sql/mysql/Mysql.sql 数据库脚本。
2.达梦数据库
创建QDATA数据库,字符集使用GB18030,大小写敏感:否,导入项目中的 sql/dm/dm.sql 数据库脚本。
二、打开项目
开发工具IDEA打开项目中的 qData 文件夹,会自动安装Maven依赖,等待安装完成,速度取决于网络。
三、修改主配置文件
位于:src/main/resources/application.yml
,具体配置项目可以参考里面的注释内容。
# 项目相关配置
qdata:
# 名称
name: qData
# 版本
version: 3.8.8
# 版权年份
copyrightYear: 2024
# 文件路径 示例( Windows配置D:/qdata/uploadPath,Linux配置 /home/qdata/uploadPath) -- 需要和 file 模块保持一致
profile: ${user.dir}/upload/
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
# 日志配置
logging:
level:
tech.qiantong: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
#万能密码 配置为空则不生效
universalPassword: gfh78h23789#$gfdy845
# Spring配置
spring:
cache:
type: jcache
jcache:
config: classpath:ehcache.xml
thymeleaf:
prefix: classpath:/dist/
mode: HTML
encoding: utf-8
cache: false
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: dev # 默认激活的环境,可以在启动时覆盖
config:
import:
- "application-${spring.profiles.active}.yml"
- "classpath:application-auth-${spring.profiles.active}.yml"
- "classpath:application-es-${spring.profiles.active}.yml"
- "classpath:application-file-${spring.profiles.active}.yml"
# 示意:引入业务模块配置文件(请按照项目情况调整)
- "classpath:application-system-${spring.profiles.active}.yml"
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 3000MB
# 设置总上传的文件大小
max-request-size: 3000MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌自定义标识
rpHeader: token
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 600
# MyBatis配置
# mybatis:
# 搜索指定包别名
# typeAliasesPackage: tech.qiantong.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
# mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
# configLocation: classpath:mybatis/mybatis-config.xml
# MyBatis Plus配置
mybatis-plus:
# 搜索指定包别名
typeAliasesPackage: tech.qiantong.**.dataobject,tech.qiantong.**.dataobject.assetchild, tech.qiantong.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
global-config:
# 关闭 MyBatis-Plus 的 Banner
banner: false
db-config:
# 主键类型 AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
idType: AUTO
# 全局逻辑删除字段名
logic-delete-field: delFlag
# 逻辑已删除值(默认为1)
logic-delete-value: 1
# 逻辑未删除值(默认为0)
logic-not-delete-value: 0
# 字段验证策略之 insert,在 insert 的时候的字段验证策略 IGNORED 忽略 NOT_NULL 非NULL NOT_EMPTY 非空 DEFAULT 默认 NEVER 不加入 SQL
insertStrategy: NOT_NULL
# 字段验证策略之 update,在 update 的时候的字段验证策略
updateStrategy: NOT_NULL
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
where-strategy: NOT_NULL
mybatis-plus-join:
# 是否打印 mybatis plus join banner,默认true
banner: false
# 全局启用副表逻辑删除,默认true。关闭后关联查询不会加副表逻辑删除
sub-table-logic: true
# 拦截器MappedStatement缓存,默认 true
ms-cache: true
# 表别名(默认 t)
table-alias: t
# 副表逻辑删除条件的位置,支持 WHERE、ON,默认 ON
logic-del-type: on
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# Swagger 分组配置
springdoc:
swagger-ui:
path: /swagger-ui.html
tags-sorter: alpha
operations-sorter: alpha
api-docs:
path: /v3/api-docs
group-configs:
- group: 'system'
paths-to-match: '/**'
packages-to-scan: tech.qiantong.qdata.module.system.controller
- group: 'example'
paths-to-match: '/**'
packages-to-scan: tech.qiantong.qdata.module.example.controller
- group: 'ai'
paths-to-match: '/**'
packages-to-scan: tech.qiantong.qdata.module.ai.controller
# Swagger 增强配置
knife4j:
enable: true
documents:
-
group: 2.X版本
name: 接口签名
locations: classpath:sign/*
setting:
language: zh-CN
enable-swagger-models: true
enable-document-manage: true
swagger-model-name: 实体类列表
enable-version: false
enable-reload-cache-parameter: false
enable-after-script: true
enable-filter-multipart-api-method-type: POST
enable-filter-multipart-apis: false
enable-request-cache: true
enable-host: false
enable-host-text: 127.0.0.1:8080
enable-home-custom: true
home-custom-path: classpath:markdown/home.md
enable-search: false
enable-footer: false
enable-footer-custom: true
footer-custom-content: Apache License 2.0 | Copyright 2025-[江苏千桐科技有限公司])
enable-dynamic-parameter: false
enable-debug: true
enable-open-api: true
enable-group: true
cors: false
production: false
basic:
enable: true
username: test
password: 12313
#ID生成器使用 为以后分布式不重复ID做应用
#工作机器ID(0~31)
id.workerId: 1
#数据中心ID(0~31)
id.datacenterId: 1
四、修改子配置文件
位于:src/main/resources/application-dev.yml
,开发环境使用,生成环境可以使用 application-prod。
# 主数据源选择
datasource:
type: mysql #目前已支持mysql、dm8
# Spring配置
spring:
# redis 配置
redis:
host: 127.0.0.1 # 地址
port: 6379 # 端口,默认为6379
database: 0 # 数据库索引
password: # 密码
timeout: 10s # 连接超时时间
lettuce:
pool:
min-idle: 0 # 连接池中的最小空闲连接
max-idle: 8 # 连接池中的最大空闲连接
max-active: 8 # 连接池的最大数据库连接数
max-wait: -1ms #连接池最大阻塞等待时间(使用负值表示没有限制)
rabbitmq:
host: 127.0.0.1
port: 5672
username: 账号
password: 密码
listener:
direct:
auto-startup: false
simple:
auto-startup: false
acknowledge-mode: manual
concurrency: 1
max-concurrency: 10
datasource:
druid:
stat-view-servlet:
enabled: false # 是否启用Druid的监控统计功能
loginUsername: qdata # 访问Druid监控页面的用户名
loginPassword: 123456 # 访问Druid监控页面的密码
dynamic:
druid:
initial-size: 5 # 连接池初始化时创建的连接数量
min-idle: 5 # 连接池中最小空闲连接数
maxActive: 20 # 连接池中最大活动连接数
maxWait: 60000 # 连接池等待连接的最长时间(毫秒)
connectTimeout: 30000 # 数据库连接超时时间(毫秒)
socketTimeout: 60000 # Socket超时时间(毫秒)
timeBetweenEvictionRunsMillis: 60000 # 空闲连接的检测周期(毫秒)
minEvictableIdleTimeMillis: 300000 # 最小空闲连接的存活时间(毫秒)
validationQuery: SELECT 1 FROM DUAL # 用于检测连接是否有效的SQL语句
testWhileIdle: true # 是否在空闲时检测连接的有效性
testOnBorrow: false # 借用连接时是否测试连接的有效性
testOnReturn: false # 归还连接时是否测试连接的有效性
poolPreparedStatements: true # 是否打开连接池的PreparedStatement缓存
maxPoolPreparedStatementPerConnectionSize: 20 # 每个连接池的PreparedStatement缓存上限
filters: stat,slf4j # 配置Druid的过滤器
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 # Druid连接属性配置
datasource:
master: # 主库数据源配置
driver-class-name: ${${datasource.type}.driver-class-name} # 动态加载的配置属性
url: ${${datasource.type}.url}
username: ${${datasource.type}.username}
password: ${${datasource.type}.password}
# MySQL配置文件
mysql:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/qdata?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
username: <数据库账号> # 替换为实际账号
password: <数据库密码> # 替换为实际密码
# 达梦配置文件
dm8:
driver-class-name: dm.jdbc.driver.DmDriver
url: jdbc:dm://127.0.0.1:5236/QDATA?STU\&zeroDateTimeBehavior=convertToNull\&useUnicode=true\&characterEncoding=utf-8\&schema=QDATA\&serverTimezone=Asia/Shanghai
username: <数据库账号> # 替换为实际账号
password: <数据库密码> # 替换为实际密码
# 调度器相关配置
ds:
base_url: http://127.0.0.1:12345/dolphinscheduler # 调度器的地址
token: <调度器令牌> # 在调度器-安全中心-令牌管理中创建
spark:
master_url: spark://127.0.0.1:7077 # 与Spark Master地址一致
main_jar: file:/dolphinscheduler/default/resources/spark-jar/qdata-etl-3.8.8.jar # 上传etl包后路径
main_class: tech.qiantong.qdata.spark.etl.EtlApplication #qdata-etl-3.8.8.jar EtlApplication main入口路口
五、修改日志配置
日志路径配置,文件位于:src/main/resources/logback.xml
# 示例( Windows配置D:/logs,Linux配置 /opt/qData/logs)
<property name="log.path" value="D:/logs" />
六、部署
1、系统运行环境
JDK = 1.8
Mysql = 5.7.0 或 DM8(大小写不敏感、GB18030编码)
Redis >= 5.0
Maven >= 3.3
RabbitMQ 无版本要求
Docker >= 1.13.1
Docker Compose >= 1.28.0
2、maven打包
在项目根目录下执行下面的命令
mvn clean package -Dmaven.test.skip
3、上传文件至服务器
复制项目中下方文件,到服务器的/opt/qdata
目录下
qdata-server/target/qdata-server.jar
qdata-server/src/docker/docker-compose.yml
qdata-server/src/docker/docker-compose.yml
qdata-server/src/docker/Dockerfile
qdata-server/src/docker/restart.sh
4、启动服务
#进入到服务目录
cd /opt/qdata
#给启动脚本添加权限
chmod +x restart.sh
#启动服务
./restart.sh