配置文件

This commit is contained in:
sxu 2025-03-01 11:26:45 +08:00
parent d3f718d199
commit 3e1b4e4467
16 changed files with 1212 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Tomcat
server:
port: 38381
# Spring
spring:
application:
# 应用名称
name: bonus-auth
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -0,0 +1,83 @@
#!/bin/bash
suffix="-smart-canteen"
jar_version="24.10.0-SNAPSHOT"
export deploy_path=/opt/webapps/bonus-houqin
export app_workspace=/opt/builds/releases/Bonus-Cloud/${jar_version}
export biz_workspace=/opt/install/jenkins_home/workspace/Bonus-Cloud-Smart-Canteen
app_source_jars=(
"bonus-auth-${jar_version}.jar"
"bonus-gateway-${jar_version}.jar"
"bonus-system-${jar_version}.jar"
"bonus-job-${jar_version}.jar"
"bonus-file-${jar_version}.jar"
"bonus-visual-monitor-${jar_version}.jar"
)
#for source_jar in "${app_source_jars[@]}"; do
# cp -f ${app_workspace}/${source_jar} $deploy_path
# echo "copied ${app_workspace}/${source_jar} to $deploy_path"
#done
for source_jar in "${app_source_jars[@]}"; do
# 获取文件名(不带目录路径)
filename=$(basename "$source_jar")
echo "filename:$filename"
# 获取文件名(不带扩展名)
base_name="${filename%.jar}"
echo "filename:$base_name"
# 构造新的文件名
new_filename="${base_name}${suffix}.jar"
echo "filename:$new_filename"
cp -f ${app_workspace}/${source_jar} "$deploy_path/$new_filename"
echo "copied ${app_workspace}/${source_jar} to '$deploy_path/$new_filename'"
done
cp -f ${biz_workspace}/"bonus-modules/bonus-smart-canteen/target/bonus-smart-canteen.jar" $deploy_path
echo "copied ${app_workspace}/${source_jar} to $deploy_path"
# Define an array of JAR files to run
jars=("bonus-auth-${jar_version}-smart-canteen.jar --spring.config.location=file:auth_bootstrap.yml"
"bonus-gateway-${jar_version}-smart-canteen.jar --spring.config.location=file:gateway_bootstrap.yml"
"bonus-system-${jar_version}-smart-canteen.jar --spring.config.location=file:system_bootstrap.yml"
"bonus-job-${jar_version}-smart-canteen.jar --spring.config.location=file:job_bootstrap.yml"
"bonus-file-${jar_version}-smart-canteen.jar --spring.config.location=file:file_bootstrap.yml"
"bonus-visual-monitor-${jar_version}-smart-canteen.jar --spring.config.location=file:visual_bootstrap.yml"
"bonus-smart-canteen.jar --spring.config.location=file:smart_canteen_bootstrap.yml"
"bonus-cust-auth.jar --spring.config.location=file:cust_auth_bootstrap.yml")
# 遍历数组并检查每个JAR文件的进程
for jar_with_args in "${jars[@]}"; do
# 提取JAR文件名不包括参数
jar=$(echo $jar_with_args | awk '{print $1}')
# 检查进程是否启动
echo "原应用程序1 $jar "
pids=$(pgrep -f $jar || true)
echo "原应用程序2 $jar "
if [ -n "$pids" ]; then
echo "$jar is running with PID(s): $pids"
# 杀死进程
for pid in $pids; do
kill -9 $pid
if [ $? -eq 0 ]; then
echo "Process $pid for $jar killed successfully"
else
echo "Failed to kill process $pid for $jar"
fi
done
else
echo "$jar is not running"
fi
done
cd $deploy_path || { echo "Failed to change directory to $deploy_path"; exit 1; }
# Iterate over the JAR files array
for jar in "${jars[@]}"; do
echo "Starting $jar"
nohup /usr/local/jdk1.8.0/bin/java -jar $jar >/dev/null 2>&1 &
done
echo "All JARs have been run successfully."

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 38383
# Spring
spring:
application:
# 应用名称
name: bonus-file
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,58 @@
# Tomcat
server:
port: 38380
servlet:
context-path: zhgd
# Spring
spring:
application:
# 应用名称
name: bonus-gateway
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
sentinel:
# 取消控制台懒加载
eager: true
transport:
# 控制台地址
dashboard: 192.168.0.14:28858
# nacos配置持久化
datasource:
ds1:
nacos:
username: nacos
password: bonus@Admin123
server-addr: 192.168.0.244:8848
namespace: smart_canteen
dataId: sentinel-bonus-gateway
groupId: DEFAULT_GROUP
data-type: json
rule-type: gw-flow
#系统 自动 加解密开关
system:
encryptEnabled: false
decryptEnabled: true
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 38384
# Spring
spring:
application:
# 应用名称
name: bonus-gen
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,344 @@
spring:
application:
name: information-server
profiles:
active: smart_canteen_test
server:
port: 49084
# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件
logging:
file:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
--- #################### 注册中心相关配置 ####################
spring:
cloud:
nacos:
username: nacos
password: bonus@Admin123
server-addr: 192.168.0.244:8848
discovery:
namespace: smart_canteen # 命名空间。这里使用 dev 开发环境
metadata:
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
--- #################### 配置中心相关配置 ####################
spring:
cloud:
nacos:
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
config:
server-addr: 192.168.0.244:8848 # Nacos 服务器地址
namespace: smart_canteen # 命名空间 dev 的ID不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId默认为 spring.application.name
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
spring:
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务
# Servlet 配置
servlet:
# 文件上传相关配置项
multipart:
max-file-size: 16MB # 单个文件大小
max-request-size: 32MB # 设置总上传的文件大小
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
# Jackson 配置项
jackson:
serialization:
write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
fail-on-empty-beans: false # 允许序列化无属性的 Bean
# Cache 配置项
cache:
type: REDIS
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# MyBatis Plus 的配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
banner: false # 关闭控制台的 Banner 打印
mybatis-plus-join:
banner: false # 关闭控制台的 Banner 打印
# Spring Data Redis 配置
spring:
data:
redis:
repositories:
enabled: false # 项目未使用到 Spring Data Redis 的 Repository所以直接禁用保证启动速度
--- #################### 定时任务相关配置 ####################
xxl:
job:
executor:
appname: ${spring.application.name} # 执行器 AppName
logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径
accessToken: default_token # 执行器通讯TOKEN
--- #################### jysoft相关配置 ####################
jysoft:
info:
version: 1.0.0
base-package: com.jysoft.module.information
web:
admin-ui:
url: http://dashboard.jysoft.com # Admin 管理后台 UI 的地址
swagger:
title: 管理后台
description: 提供管理员管理的所有功能
version: ${jysoft.info.version}
base-package: ${jysoft.info.base-package}
captcha:
enable: false # 验证码的开关,默认为 true
tenant: # 多租户相关配置项
enable: true
ignore-urls:
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
- /admin-api/system/captcha/get-image # 获取图片验证码,和租户无关
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
- /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号
- /admin-api/system/auth/login # 账密登录,不需要租户编号
- /rpc-api/system/tenant/valid # 防止递归。避免调用 /rpc-api/system/tenant/valid 接口时,又去触发 /rpc-api/system/tenant/valid 去校验
- /rpc-api/system/tenant/id-list # 获得租户列表的时候,无需传递租户编号
- /rpc-api/system/error-code/* # 错误码的自动创建与下载的接口,无法带上租户编号
- /rpc-api/system/oauth2/token/check # 访问令牌校验时,无需传递租户编号;主要解决上传文件的场景,前端不会传递 tenant-id
ignore-tables:
- system_tenant
- system_tenant_package
- system_dict_data
- system_dict_type
- system_error_code
- system_menu
- system_sms_channel
- system_sms_template
- system_sms_log
- system_sensitive_word
- system_oauth2_client
- system_mail_account
- system_mail_template
- system_mail_log
- system_notify_template
- app_menu
- app_role
- app_role_menu
- app_user_role
- green_dictionary_info
- green_calendar
- green_day
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m
send-maximum-quantity-per-day: 10
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
debug: true
ml:
mlurl: http://localhost:8080
niu:
niupayurl: https://dev06.xnzn.net/tengyun-api/leopen/pay/device #测试地址食堂支付
niusearchuserurl: https://dev06.xnzn.net/tengyun-api/leopen/customer/query #测试地址查询用户
niupayreturnurl: https://dev06.xnzn.net/tengyun-api/leopen/pay/refund #测试地址食堂支付退钱
applicationid: 104027978266054656
applicationidpsw: 082d5733fc44443e992071b2bc916620
sncode: 001
serialnum: 02022840
#niu:
# niupayurl: http://10.138.55.106:58100/tengyun-api/leopen/pay/device #地址食堂支付
# niusearchuserurl: http://10.138.55.106:58100/tengyun-api/leopen/customer/query #地址查询用户
# niupayreturnurl: http://10.138.55.106:58100/tengyun-api/leopen/pay/refund #地址食堂支付退钱
# applicationid: 396571655104630784
# applicationidpsw: ee75c51b4a854c43ad9a85560f024068
# sncode: 2ad34554g2 #虚拟支付设备
# serialnum: 02022840
--- #################### 数据库相关配置 ####################
spring:
# 数据源配置项
autoconfigure:
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
datasource:
druid: # Druid 【监控】相关的全局配置
web-stat-filter:
enabled: true
stat-view-servlet:
enabled: true
allow: # 设置白名单,不填则允许所有访问
url-pattern: /druid/*
login-username: # 控制台管理用户名和密码
login-password:
filter:
stat:
enabled: true
log-slow-sql: true # 慢 SQL 记录
slow-sql-millis: 100
merge-sql: true
wall:
config:
multi-statement-allow: true
dynamic: # 多数据源配置
druid: # Druid 【连接池】相关的全局配置
initial-size: 1 # 初始连接数
min-idle: 1 # 最小连接池数量
max-active: 20 # 最大连接池数量
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
test-while-idle: true
test-on-borrow: false
test-on-return: false
primary: master
datasource:
master:
name: sbd-zhhq
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://220.248.250.227:49961/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
#url: jdbc:mysql://localhost:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
# url: jdbc:mysql://10.138.55.104:13306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
# username: jysoft
username: root
password: root
# password: jysoft@sbd1
# password: Jysoft@#2023
# username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
# slave: # 模拟从库,可根据自己需要修改
# name: roof-vue-pro
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
# username: root
# password: 123456
# username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
port: 6379 # 端口
database: 0 # 数据库索引
# password: 123456 # 密码,建议生产环境开启
--- #################### MQ 消息队列相关配置 ####################
#spring:
# cloud:
# stream:
# rocketmq:
# # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类
# binder:
# name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址
# binding-retry-interval: 7200 # 消息绑定重试间隔时间,单位:秒,默认为 30 秒。考虑到本地可能不启动 RocketMQ 服务,设置为 2 小时
--- #################### 定时任务相关配置 ####################
xxl:
job:
enabled: false # 是否开启调度中心,默认为 true 开启
admin:
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项
lock4j:
acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
--- #################### 监控相关配置 ####################
# Spring Boot Admin 配置项
spring:
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
instance:
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
# 日志文件配置
logging:
level:
# 配置自己写的 MyBatis Mapper 打印日志
com.jysoft.information.web.mapper: debug
com.jysoft.information.app.mapper: debug
--- #################### jysoft相关配置 ####################
# jysoft配置项设置当前项目所有自定义的配置
jysoft:
env: # 多环境的配置项
tag: ${HOSTNAME}
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试
security:
mock-enable: true
xss:
enable: false
exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
access-log: # 访问日志的配置项
enable: false
server:
tomcat:
initial-memory: 128m
max-memory: 256m

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 38385
# Spring
spring:
application:
# 应用名称
name: bonus-job
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,129 @@
AUTH_RESOURCE_NAME=bonus-auth-24.10.0-SNAPSHOT-smart-canteen.jar
GATEWAY_RESOURCE_NAME=bonus-gateway-24.10.0-SNAPSHOT-smart-canteen.jar
SYS_RESOURCE_NAME=bonus-system-24.10.0-SNAPSHOT-smart-canteen.jar
JOB_RESOURCE_NAME=bonus-job-24.10.0-SNAPSHOT-smart-canteen.jar
FILE_RESOURCE_NAME=bonus-file-24.10.0-SNAPSHOT-smart-canteen.jar
MONITOR_RESOURCE_NAME=bonus-visual-monitor-24.10.0-SNAPSHOT-smart-canteen.jar
SMART_CANTEEN_RESOURCE_NAME=bonus-smart-canteen.jar
BONUS_CUST_AUTH_RESOURCE_NAME=bonus-cust-auth.jar
tpid=`ps -ef|grep $AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $GATEWAY_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $GATEWAY_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $SYS_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $SYS_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $JOB_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $JOB_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $FILE_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $FILE_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $MONITOR_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $MONITOR_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $SMART_CANTEEN_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $SMART_CANTEEN_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
tpid=`ps -ef|grep $BONUS_CUST_AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $BONUS_CUST_AUTH_RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi

View File

@ -0,0 +1,217 @@
spring:
application:
name: log-server
profiles:
active: smart_canteen_test
server:
port: 49091
# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件
logging:
file:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
--- #################### 注册中心相关配置 ####################
spring:
cloud:
nacos:
username: nacos
password: bonus@Admin123
server-addr: 192.168.0.244:8848
discovery:
namespace: smart_canteen # 命名空间。这里使用 dev 开发环境
metadata:
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
--- #################### 配置中心相关配置 ####################
spring:
cloud:
nacos:
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
config:
server-addr: 192.168.0.244:8848 # Nacos 服务器地址
namespace: smart_canteen # 命名空间 dev 的ID不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId默认为 spring.application.name
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
spring:
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
# Jackson 配置项
jackson:
serialization:
write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
fail-on-empty-beans: false # 允许序列化无属性的 Bean
# Cache 配置项
cache:
type: REDIS
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# MyBatis Plus 的配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
banner: false # 关闭控制台的 Banner 打印
encryptor:
password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成
mybatis-plus-join:
banner: false # 关闭控制台的 Banner 打印
# Spring Data Redis 配置
spring:
data:
redis:
repositories:
enabled: false # 项目未使用到 Spring Data Redis 的 Repository所以直接禁用保证启动速度
--- #################### jysoft相关配置 ####################
jysoft:
info:
version: 1.0.0
base-package: com.jysoft.module.log
web:
admin-ui:
url: http://dashboard.jysoft.com # Admin 管理后台 UI 的地址
swagger:
title: 管理后台
description: 提供审计日志管理
version: ${jysoft.info.version}
base-package: ${jysoft.info.base-package}
tenant: # 多租户相关配置项
enable: true
debug: false
--- #################### 数据库相关配置 ####################
spring:
# 数据源配置项
autoconfigure:
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
datasource:
druid: # Druid 【监控】相关的全局配置
web-stat-filter:
enabled: true
stat-view-servlet:
enabled: true
allow: # 设置白名单,不填则允许所有访问
url-pattern: /druid/*
login-username: # 控制台管理用户名和密码
login-password:
filter:
stat:
enabled: true
log-slow-sql: true # 慢 SQL 记录
slow-sql-millis: 100
merge-sql: true
wall:
config:
multi-statement-allow: true
dynamic: # 多数据源配置
druid: # Druid 【连接池】相关的全局配置
initial-size: 1 # 初始连接数
min-idle: 1 # 最小连接池数量
max-active: 20 # 最大连接池数量
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
test-while-idle: true
test-on-borrow: false
test-on-return: false
primary: master
datasource:
master:
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://220.248.250.227:49961/sbd_zhhq?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
url: jdbc:mysql://localhost:3306/sbd-zhhq?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
# username: jysoft
username: root
password: root
# password: Jysoft@#2023
# username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
# slave: # 模拟从库,可根据自己需要修改
# name: roof-vue-pro
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
# username: root
# password: 123456
# username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
--- #################### 监控相关配置 ####################
# 日志文件配置
logging:
level:
# 配置自己写的 MyBatis Mapper 打印日志
com.jysoft.module.log.dal.mapper: debug
--- #################### 定时任务配置多租户需求 ####################
xxl:
job:
enabled: false # 是否开启调度中心,默认为 true 开启
admin:
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
--- #################### jysoft相关配置 ####################
# jysoft配置项设置当前项目所有自定义的配置
jysoft:
env: # 多环境的配置项
tag: ${HOSTNAME}
security:
mock-enable: true
access-log: # 访问日志的配置项
enable: true
server:
tomcat:
initial-memory: 128m
max-memory: 256m

View File

@ -0,0 +1,80 @@
pipeline {
agent any
environment {
// 设置自定义JDK路径因为每个项目可能需要不同版本的jdk
JAVA_HOME = '/usr/lib/jvm/jdk1.8.0_381'
JOBNAME="${JOB_NAME}"
JENKINS_NODE_COOKIE = "dontKillMe"
#SPRING_PROFILES_ACTIVE = "dev"
}
stages {
stage('Check out') {
steps {
withCredentials([usernamePassword(credentialsId: 'f7070987-9b49-4ae1-af6d-53a3bf26799b', passwordVariable: 'Max@2023', usernameVariable: 'bonus')]) {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'http://192.168.0.244:3000/bonus/Bonus-Cloud-Smart-Canteen.git']]
])
}
}
}
stage('Move file') {
steps {
echo 'move file start!'
sh 'chmod 777 ${WORKSPACE}/scripts/*'
// 如果需要拷贝文件,打开并编写以下脚本
// sh '${WORKSPACE}/scripts/moveFile.sh'
}
}
stage('Build') {
steps {
echo 'build start!'
sh 'env JAVA_HOME=$JAVA_HOME /usr/local/src/apache-maven-3.9.4/bin/mvn clean package'
}
}
stage('Sonar scan') {
steps {
script {
echo 'sonar scan start!'
def scannerHome = tool 'sonar-scanner'
withSonarQubeEnv('sonarqube-server') {
sh "/usr/local/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner " +
"-Dsonar.projectKey=${JOB_NAME} " +
"-Dsonar.projectName=${JOB_NAME} " +
"-Dsonar.sourceEncoding=UTF-8 " +
"-Dsonar.language=java " +
"-Dsonar.projectVersion=1.0 " +
"-Dsonar.sources=. " +
"-Dsonar.java.source=1.8 " +
"-Dsonar.java.target=1.8 " +
"-Dsonar.scm.disabled=true " +
"-Dsonar.exclusions=test/**,node_modules/**,static/**,**/*.js,**/*.html,**/*.css,**/*.jar " +
"-Dsonar.java.binaries=**/target/classes"
}
}
}
}
stage('Deploy') {
steps {
echo 'deploy start!'
sh '''BUILD_ID=DONTKILLME sh ${WORKSPACE}/scripts/deploy.sh'''
}
}
stage('Dingding') {
steps {
echo 'Dingding start!'
script {
def webhookUrl = 'https://oapi.dingtalk.com/robot/send?access_token=eae0af98514a0db9a9a0d5cd8e337d13e7c16cd81d4a90b503e465a573020add' //替换为你自己的钉钉机器人Webhook地址
def message = "${JOB_NAME} TEST已完成: ${env.BUILD_URL} \n 到Sonarqube查看问题http://192.168.0.244:9000/dashboard?id=${JOB_NAME} \n 查看新包: http://192.168.0.244/${JOB_NAME}/${BUILD_NUMBER} "
echo "${message}"
sh "curl -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\", \"text\": {\"content\": \"${message}\"}, \"at\": {\"atMobiles\": [\"张三,李四\"], \"isAtAll\": true}}' ${webhookUrl}"
}
}
}
}
}

View File

@ -0,0 +1,34 @@
# Tomcat
server:
port: 38389
# Spring
spring:
servlet:
multipart:
# 文件最大
max-file-size: 20MB
# 设置总上传数据总大小
max-request-size: 20MB
application:
# 应用名称
name: bonus-shared-station
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,37 @@
# Tomcat
server:
port: 38388
# Spring
spring:
servlet:
multipart:
# 文件最大
max-file-size: 20MB
# 设置总上传数据总大小
max-request-size: 20MB
application:
# 应用名称
name: bonus-smart-canteen
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,7 @@
P_ID=$(pgrep -f BonusSmartCanteenApplication)
if [ -z "$P_ID" ]; then
echo "BonusSmartCanteenApplication is not running"
else
kill -9 "$P_ID"
fi

View File

@ -0,0 +1,39 @@
# Tomcat
server:
port: 48081
# Spring
spring:
servlet:
multipart:
# 文件最大
max-file-size: 20MB
# 设置总上传数据总大小
max-request-size: 20MB
application:
# 应用名称
name: system-server
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,33 @@
# Tomcat
server:
port: 38382
# Spring
spring:
application:
# 应用名称
name: bonus-system
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
system:
supports:
phoneLogin: true
emailLogin: true

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 38386
# Spring
spring:
application:
# 应用名称
name: bonus-monitor
profiles:
# 环境配置
active: smart_canteen_test
cloud:
nacos:
username: nacos
password: bonus@Admin123
discovery:
# 服务注册地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
config:
# 配置中心地址
server-addr: 192.168.0.244:8848
namespace: smart_canteen
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}