若依(ruoyi)的后端调整私有化项目的过程
以下文章来源于Hing-Zhang
正文
若依项目替换为projectName项目配置及部署步骤
文章目录
更换名称
后端
更换项目及模块名称
-
下载项目
-
不打卡项目
- 在文件夹中更改文件目录名称:包括所有的模块文件夹的名称,包名称不更改
-
打开项目
-
在idea中替换所有的pom.xml中涉及到ruoyi的地方
-
如果已经生成iml则更改iml文件的名称涉及到ruoyi的地方
-
重新构建
-
更换包名称
将包名rouyi更改为projectName
更新启动类名称
将启动类变为projectName开头的projectNamexxxxAppilication.java
更新author注释
@author advantecher
其他内部配置
验证码报错
更新控制台打印信息
工具地址:http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something%20
更新所有的Application控制台打印信息
更新所有的启动成功控制台打印信息(所有的banner.txt文件)
数据库
nocos的配置表config_info
更改content的包含ruoyi的参数值,参考下边的配置内容
配置文件
application-dev.yml
spring:
main:
allow-bean-definition-overriding: true
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
#请求处理的超时时间
ribbon:
ReadTimeout: 10000
ConnectTimeout: 10000
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: '*'
projectName-gateway-dev.yml
spring:
redis:
host: 172.22.24.139
port: 6379
password:
cloud:
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
routes:
# 认证中心
- id: projectName-auth
uri: lb://projectName-auth
predicates:
- Path=/auth/**
filters:
# 验证码处理
- CacheRequestFilter
- ValidateCodeFilter
- StripPrefix=1
# 代码生成
- id: projectName-gen
uri: lb://projectName-gen
predicates:
- Path=/code/**
filters:
- StripPrefix=1
# 定时任务
- id: projectName-job
uri: lb://projectName-job
predicates:
- Path=/schedule/**
filters:
- StripPrefix=1
# 系统模块
- id: projectName-system
uri: lb://projectName-system
predicates:
- Path=/system/**
filters:
- StripPrefix=1
# 文件服务
- id: projectName-file
uri: lb://projectName-file
predicates:
- Path=/file/**
filters:
- StripPrefix=1
# 不校验白名单
ignore:
whites:
- /auth/logout
- /auth/login
- /*/v2/api-docs
- /csrf
projectName-auth-dev.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Ab123456
redis:
host: 172.22.24.139
port: 6379
password:
projectName-monitor-dev.yml
spring
spring:
security:
user:
name: ruoyi
password: 123456
boot:
admin:
ui:
title: 项目名服务状态监控
projectName-system-dev.yml
spring配置
spring:
redis:
host: 172.22.24.139
port: 6379
password:
datasource:
druid:
stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic:
druid:
initial-size: 5
min-idle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat,wall,slf4j
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
# 主库数据源
master:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Ab123456
# 从库数据源
# slave:
# url:
# username:
# password:
# driver-class-name:
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.projectName.system
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
# swagger配置
swagger:
title: 系统模块接口文档
license: Powered By ruoyi
licenseUrl: https://ruoyi.vip
authorization:
name: RuoYi OAuth
auth-regex: ^.*$
authorization-scope-list:
- scope: server
description: 客户端授权范围
token-url-list:
- http://localhost:8080/auth/oauth/token
projectName-gen-dev.yml
spring配置
spring:
redis:
host: 172.22.24.139
port: 6379
password:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Ab123456
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.projectName.gen.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
# swagger配置
swagger:
title: 代码生成接口文档
license: Powered By ruoyi
licenseUrl: https://ruoyi.vip
authorization:
name: RuoYi OAuth
auth-regex: ^.*$
authorization-scope-list:
- scope: server
description: 客户端授权范围
token-url-list:
- http://localhost:8080/auth/oauth/token
# 代码生成
gen:
# 作者
author: ruoyi
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: com.projectName.system
# 自动去除表前缀,默认是false
autoRemovePre: false
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: sys_
projectName-job-dev.yml
spring配置
spring:
redis:
host: 172.22.24.139
port: 6379
password:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Ab123456
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.projectName.job.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
# swagger配置
swagger:
title: 定时任务接口文档
license: Powered By ruoyi
licenseUrl: https://ruoyi.vip
authorization:
name: RuoYi OAuth
auth-regex: ^.*$
authorization-scope-list:
- scope: server
description: 客户端授权范围
token-url-list:
- http://localhost:8080/auth/oauth/token
projectName-file-dev.yml
# 本地文件上传
file:
domain: http://127.0.0.1:9300
path: D:/ruoyi/uploadPath
prefix: /statics
# FastDFS配置
fdfs:
domain: http://8.129.231.12
soTimeout: 3000
connectTimeout: 2000
trackerList: 8.129.231.12:22122
# Minio配置
minio:
url: http://8.129.231.12:9000
accessKey: minioadmin
secretKey: minioadmin
bucketName: test
sentinel-projectName-gateway
[
{
"resource": "projectName-auth",
"count": 500,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "projectName-system",
"count": 1000,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "projectName-gen",
"count": 200,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
},
{
"resource": "projectName-job",
"count": 300,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0
}
]
pom文件
ParentProject
#去掉最外层 <modules></modules>
#增加parent项目
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.aicyber</groupId>
<artifactId>spring-cloud-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<name>spring-cloud-parent</name>
<url>http://www.aicyber.com/</url>
<description>知识图谱微服务SaaS系统</description>
<distributionManagement>
<repository>
<id>releases</id>
<name>Release</name>
<url>https://devrepo.devcloud.huaweicloud.com/02/nexus/content/repositories/97016cb28c464934b5ca65d9dd7c76d0_1_0/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshot</name>
<url>https://devrepo.devcloud.huaweicloud.com/02/nexus/content/repositories/97016cb28c464934b5ca65d9dd7c76d0_2_0/</url>
</snapshotRepository>
</distributionManagement>
<properties>
<knowledgeGraph.version>1.0.0${env.version}</knowledgeGraph.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version>
<spring-cloud-alibaba-nacos.version>1.8.0</spring-cloud-alibaba-nacos.version>
<spring-cloud-alibaba-dependencies.version>2.2.1.RELEASE</spring-cloud-alibaba-dependencies.version>
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
<spring-boot.mybatis>2.1.4</spring-boot.mybatis>
<spring-boot.Openfeign>2.2.6.RELEASE</spring-boot.Openfeign>
<swagger.fox.version>2.9.2</swagger.fox.version>
<swagger.core.version>1.5.24</swagger.core.version>
<tobato.version>1.26.5</tobato.version>
<kaptcha.version>2.3.2</kaptcha.version>
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
<druid.version>1.2.4</druid.version>
<dynamic-ds.version>3.2.1</dynamic-ds.version>
<commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<velocity.version>1.7</velocity.version>
<fastjson.version>1.2.75</fastjson.version>
<minio.version>8.0.3</minio.version>
<poi.version>4.1.2</poi.version>
<common-pool.version>2.6.2</common-pool.version>
</properties>
<!-- spring-cloud-dependencies -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- SpringBoot 依赖配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- SpringBoot 监控客户端 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<!-- FastDFS 分布式文件系统 -->
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>${tobato.version}</version>
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${spring-boot.mybatis}</version>
</dependency>
<!-- Swagger 依赖配置 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger.core.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.core.version}</version>
</dependency>
<!-- 验证码 -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>${kaptcha.version}</version>
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>
<!-- io常用工具类 -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- 文件上传工具类 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileupload.version}</version>
</dependency>
<!-- 代码生成使用模板 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>${velocity.version}</version>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JSON 解析器和生成器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- 公共资源池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${common-pool.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
<env.version>-SNAPSHOT</env.version>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>uat</id>
<properties>
<env>uat</env>
<env.version></env.version>
</properties>
</profile>
<profile>
<id>prd</id>
<properties>
<env>prd</env>
<env.version></env.version>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
SubProject
#去掉api、moudles、visual最外层的pom的<modules></modules>,保留common项目的pom
#继承parent项目,修改打包说明
<parent>
<groupId>com.aicyber</groupId>
<artifactId>spring-cloud-parent</artifactId>
<version>1.0.0</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.aicyber</groupId>
<artifactId>knowledgeGraph-visual-monitor</artifactId>
<version>1.0.0${env.version}</version>
<packaging>jar</packaging>
<description>
knowledgeGraph-visual-monitor监控中心
</description>
打包部署
全局替换nacos地址
127.0.0.1:8848
到
部署nacos的ip:8848
打包
mvn clean package
将jar包部署到服务器
nohup java -jar projectName-gateway.jar >gateway.log 2>&1 &
nohup java -jar projectName-visual-monitor.jar >monitor.log 2>&1 &
nohup java -jar projectName-auth.jar >auth.log 2>&1 &
nohup java -jar projectName-modules-system.jar >system.log 2>&1 &
nohup java -jar projectName-modules-gen.jar >gen.log 2>&1 &
nohup java -jar projectName-modules-job.jar >job.log 2>&1 &
nohup java -jar projectName-modules-file.jar >file.log 2>&1 &
批量部署文件
#!/bin/sh
#chkconfig: 2345 80 05
#description: projectName
##jar包
export GATEWAY=/usr/local/projectName/jar/projectName-gateway.jar
export MONITOR=/usr/local/projectName/jar/projectName-visual-monitor.jar
export AUTH=/usr/local/projectName/jar/projectName-auth.jar
export SYSTEM=/usr/local/projectName/jar/projectName-modules-system.jar
export GEN=/usr/local/projectName/jar/projectName-modules-gen.jar
export JOB=/usr/local/projectName/jar/projectName-modules-job.jar
export FILE=/usr/local/projectName/jar/projectName-modules-file.jar
##端口
export GATEWAY_port=8080
export MONITOR_port=9100
export AUTH_port=9200
export SYSTEM_port=9201
export GEN_port=9202
export JOB_port=9203
export FILE_port=9300
##日志
export GATEWAY_log=/usr/local/projectName/log/GATEWAY.out
export MONITOR_log=/usr/local/projectName/log/MONITOR.out
export AUTH_log=/usr/local/projectName/log/AUTH.out
export SYSTEM_log=/usr/local/projectName/log/SYSTEM.out
export GEN_log=/usr/local/projectName/log/GEN.out
export JOB_log=/usr/local/projectName/log/JOB.out
export FILE_log=/usr/local/projectName/log/FILE.out
##配置文件,dev/prod
export spring_config=dev
case "$1" in
start)
## 启动GATEWAY
echo "--------GATEWAY 开始启动--------------"
nohup java -jar $GATEWAY --spring.profiles.active=$spring_config >$GATEWAY_log 2>&1 &
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$GATEWAY_pid" ]
do
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
done
echo "GATEWAY pid is $GATEWAY_pid"
echo "--------GATEWAY 启动成功--------------"
## 启动MONITOR
echo "--------MONITOR 开始启动--------------"
nohup java -jar $MONITOR --spring.profiles.active=$spring_config >$MONITOR_log 2>&1 &
MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$MONITOR_pid" ]
do
MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'`
done
echo "MONITOR pid is $MONITOR_pid"
echo "--------MONITOR 启动成功--------------"
## 启动AUTH
echo "--------AUTH 开始启动--------------"
nohup java -jar $AUTH --spring.profiles.active=$spring_config >$AUTH_log 2>&1 &
AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$AUTH_pid" ]
do
AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
done
echo "AUTH pid is $AUTH_pid"
echo "--------AUTH 启动成功--------------"
## 启动SYSTEM
echo "--------SYSTEM 开始启动--------------"
nohup java -jar $SYSTEM --spring.profiles.active=$spring_config >$SYSTEM_log 2>&1 &
SYSTEM_pid=`lsof -i:$SYSTEM_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$SYSTEM_pid" ]
do
SYSTEM_pid=`lsof -i:$SYSTEM_port|grep "LISTEN"|awk '{print $2}'`
done
echo "SYSTEM pid is $SYSTEM_pid"
echo "--------SYSTEM 启动成功--------------"
## 启动GEN
echo "--------GEN 开始启动--------------"
nohup java -jar $GEN --spring.profiles.active=$spring_config >$GEN_log 2>&1 &
GEN_pid=`lsof -i:$GEN_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$GEN_pid" ]
do
GEN_pid=`lsof -i:$GEN_port|grep "LISTEN"|awk '{print $2}'`
done
echo "GEN pid is $GEN_pid"
echo "--------GEN 启动成功--------------"
## 启动JOB
echo "--------JOB 开始启动--------------"
nohup java -jar $JOB --spring.profiles.active=$spring_config >$JOB_log 2>&1 &
JOB_pid=`lsof -i:$JOB_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$JOB_pid" ]
do
JOB_pid=`lsof -i:$JOB_port|grep "LISTEN"|awk '{print $2}'`
done
echo "JOB pid is $JOB_pid"
echo "--------JOB 启动成功--------------"
## 启动FILE
echo "--------FILE 开始启动--------------"
nohup java -jar $FILE --spring.profiles.active=$spring_config >$FILE_log 2>&1 &
FILE_pid=`lsof -i:$FILE_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$FILE_pid" ]
do
FILE_pid=`lsof -i:$FILE_port|grep "LISTEN"|awk '{print $2}'`
done
echo "FILE pid is $FILE_pid"
echo "--------FILE 启动成功--------------"
echo "===startAll success==="
;;
stop)
P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===GATEWAY process not exists or stop success"
else
kill -9 $P_ID
echo "GATEWAY killed success"
fi
P_ID=`ps -ef | grep -w $MONITOR | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===MONITOR process not exists or stop success"
else
kill -9 $P_ID
echo "MONITOR killed success"
fi
P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===AUTH process not exists or stop success"
else
kill -9 $P_ID
echo "AUTH killed success"
fi
P_ID=`ps -ef | grep -w $SYSTEM | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===SYSTEM process not exists or stop success"
else
kill -9 $P_ID
echo "SYSTEM killed success"
fi
P_ID=`ps -ef | grep -w $GEN | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===GEN process not exists or stop success"
else
kill -9 $P_ID
echo "GEN killed success"
fi
P_ID=`ps -ef | grep -w $JOB | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===JOB process not exists or stop success"
else
kill -9 $P_ID
echo "JOB killed success"
fi
P_ID=`ps -ef | grep -w $FILE | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===FILE process not exists or stop success"
else
kill -9 $P_ID
echo "FILE killed success"
fi
echo "===stopAll success==="
;;
restart)
$0 stop
sleep 2
$0 start
echo "===restartAll success==="
;;
esac
exit 0
单个部署文件
#!/bin/sh
#chkconfig: 2345 80 06
#description: gollum
##jar包
export GATEWAY=/usr/local/projectName/jar/projectName-gateway.jar
export MONITOR=/usr/local/projectName/jar/projectName-visual-monitor.jar
export AUTH=/usr/local/projectName/jar/projectName-auth.jar
export SYSTEM=/usr/local/projectName/jar/projectName-modules-system.jar
export GEN=/usr/local/projectName/jar/projectName-modules-gen.jar
export JOB=/usr/local/projectName/jar/projectName-modules-job.jar
export FILE=/usr/local/projectName/jar/projectName-modules-file.jar
##端口
export GATEWAY_port=8080
export MONITOR_port=9100
export AUTH_port=9200
export SYSTEM_port=9201
export GEN_port=9202
export JOB_port=9203
export FILE_port=9300
##日志
export GATEWAY_log=/usr/local/projectName/log/GATEWAY.out
export MONITOR_log=/usr/local/projectName/log/MONITOR.out
export AUTH_log=/usr/local/projectName/log/AUTH.out
export SYSTEM_log=/usr/local/projectName/log/SYSTEM.out
export GEN_log=/usr/local/projectName/log/GEN.out
export JOB_log=/usr/local/projectName/log/JOB.out
export FILE_log=/usr/local/projectName/log/FILE.out
##配置文件,dev/prod
export spring_config=dev
case "$1" in
start)
case "$2" in
gateway|GATEWAY)
## 启动GATEWAY
echo "--------GATEWAY 开始启动--------------"
nohup java -jar $GATEWAY --spring.profiles.active=$spring_config >$GATEWAY_log 2>&1 &
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$GATEWAY_pid" ]
do
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
done
echo "GATEWAY pid is $GATEWAY_pid"
echo "--------GATEWAY 启动成功--------------"
;;
monitor|MONITOR)
## 启动MONITOR
echo "--------MONITOR 开始启动--------------"
nohup java -jar $MONITOR --spring.profiles.active=$spring_config >$MONITOR_log 2>&1 &
MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$MONITOR_pid" ]
do
MONITOR_pid=`lsof -i:$MONITOR_port|grep "LISTEN"|awk '{print $2}'`
done
echo "MONITOR pid is $MONITOR_pid"
echo "--------MONITOR 启动成功--------------"
;;
auth|AUTH)
## 启动AUTH
echo "--------AUTH 开始启动--------------"
nohup java -jar $AUTH --spring.profiles.active=$spring_config >$AUTH_log 2>&1 &
AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$AUTH_pid" ]
do
AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk '{print $2}'`
done
echo "AUTH pid is $AUTH_pid"
echo "--------AUTH 启动成功--------------"
;;
system|SYSTEM)
## 启动SYSTEM
echo "--------SYSTEM 开始启动--------------"
nohup java -jar $SYSTEM --spring.profiles.active=$spring_config >$SYSTEM_log 2>&1 &
SYSTEM_pid=`lsof -i:$SYSTEM_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$SYSTEM_pid" ]
do
SYSTEM_pid=`lsof -i:$SYSTEM_port|grep "LISTEN"|awk '{print $2}'`
done
echo "SYSTEM pid is $SYSTEM_pid"
echo "--------SYSTEM 启动成功--------------"
;;
gen|GEN)
## 启动GEN
echo "--------GEN 开始启动--------------"
nohup java -jar $GEN --spring.profiles.active=$spring_config >$GEN_log 2>&1 &
GEN_pid=`lsof -i:$GEN_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$GEN_pid" ]
do
GEN_pid=`lsof -i:$GEN_port|grep "LISTEN"|awk '{print $2}'`
done
echo "GEN pid is $GEN_pid"
echo "--------GEN 启动成功--------------"
;;
job|JOB)
## 启动JOB
echo "--------JOB 开始启动--------------"
nohup java -jar $JOB --spring.profiles.active=$spring_config >$JOB_log 2>&1 &
JOB_pid=`lsof -i:$JOB_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$JOB_pid" ]
do
JOB_pid=`lsof -i:$JOB_port|grep "LISTEN"|awk '{print $2}'`
done
echo "JOB pid is $JOB_pid"
echo "--------JOB 启动成功--------------"
;;
files|FILE)
## 启动FILE
echo "--------FILE 开始启动--------------"
nohup java -jar $FILE --spring.profiles.active=$spring_config >$FILE_log 2>&1 &
FILE_pid=`lsof -i:$FILE_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$FILE_pid" ]
do
FILE_pid=`lsof -i:$FILE_port|grep "LISTEN"|awk '{print $2}'`
done
echo "FILE pid is $FILE_pid"
echo "--------FILE 启动成功--------------"
;;
esac
;;
stop)
case "$2" in
gateway|GATEWAY)
P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===GATEWAY process not exists or stop success"
else
kill -9 $P_ID
echo "GATEWAY killed success"
fi
;;
monitor|MONITOR)
P_ID=`ps -ef | grep -w $MONITOR | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===MONITOR process not exists or stop success"
else
kill -9 $P_ID
echo "MONITOR killed success"
fi
;;
auth|AUTH)
P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===AUTH process not exists or stop success"
else
kill -9 $P_ID
echo "AUTH killed success"
fi
;;
system|SYSTEM)
P_ID=`ps -ef | grep -w $SYSTEM | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===SYSTEM process not exists or stop success"
else
kill -9 $P_ID
echo "SYSTEM killed success"
fi
;;
gen|GEN)
P_ID=`ps -ef | grep -w $GEN | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===GEN process not exists or stop success"
else
kill -9 $P_ID
echo "GEN killed success"
fi
;;
job|JOB)
P_ID=`ps -ef | grep -w $JOB | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===JOB process not exists or stop success"
else
kill -9 $P_ID
echo "JOB killed success"
fi
;;
files|FILE)
P_ID=`ps -ef | grep -w $FILE | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===FILE process not exists or stop success"
else
kill -9 $P_ID
echo "FILE killed success"
fi
;;
esac
;;
restart)
$0 stop $2
sleep 2
$0 start $2
echo "===restart $2 success==="
;;
esac
exit 0 ## <a id="_29"></a>批量部署命令
#去除无效字符
sed -i 's/\r$//' projectName.sh
#权限
chmod +7 projectName.sh
#全部启动
sudo sh projectName.sh start
sudo sh projectName.sh restart
sudo sh projectName.sh stop
#单个启动
sh projectName-one.sh start system
...
添加模块
1 、新增模块
2、参考其他模块配置pom
3、配置启动类application
4、在nacos增加配置文件信息
5、编写代码…
6、配置nacos的gateway网关
7、访问swagger
**Authorize= Bearer +空格+Token**
Bearer a4bcfd07-ce3f-451f-8f02-32451fc8ac85
任意的请求都包含token信息,将token信息输入到**Authorization**中
数据权限
规则:根据当前登录用户的角色的数据权限设置用户能够查看哪些部门的数据,admin具有全部权限
步骤
-
设置角色权限,(首先获取登录用户的角色的权限标识)
当前支持的数据权限:
-
全部数据权限
无条件设置
-
自定数据权限,(设置角色的数据权限的时候自定义的可以访问的部门权限)
sqlString.append(StringUtils.format( “ OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) “, deptAlias, role.getRoleId()));
-
部门数据权限(当前用户所在部门的数据)
sqlString.append(StringUtils.format(“ OR {}.dept_id = {} “, deptAlias, user.getDeptId()));
-
部门及以下数据权限(部门及子部门数据权限)
String.append(StringUtils.format( “ OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )”, deptAlias, user.getDeptId(), user.getDeptId()));
-
仅本人数据权限 (此权限要求数据关联用户字段,否则查询不到任何的数据)
if (StringUtils.isNotBlank(userAlias)) { sqlString.append(StringUtils.format(“ OR {}.user_id = {} “, userAlias, user.getUserId())); } else { // 数据权限为仅本人且没有userAlias别名不查询任何数据 sqlString.append(“ OR 1=0 “); }
-
-
在需要数据权限控制方法上添加
@DataScope
注解,其中d
和u
用来表示表的别名(在SQL中用户及部门表的别名)// 部门数据权限注解 @DataScope(deptAlias = “u”) // 部门及用户权限注解 @DataScope(deptAlias = “d”, userAlias = “u”)
-
在
mybatis
查询底部标签添加数据范围过滤${params.dataScope}
应用
在设计功能需要数据权限的时候,信息的保存及修改增加当前登录用户的信息存储。
使用用户的信息而不使用部门的信息作为权限的依据:可以避免更换部门等操作带来的其他影响等
功能分析
日志
日志记录类设计:需要进行检索及统计的详细信息属性定义
日志时间:当前写日志的时间,避免日志写入ES的延迟
服务ID
服务名称
服务处理步骤:预先定义好,例如:输入端输入;groovy处理;输出端输出…
消息:具体的消息
日志信息记录方式:考虑MQ的发布订阅模式处理日志信息存入ElasticSearch,
ES:方便搜索海量日志
MQ:避免日志记录到ES中异常情况对程序的影响
索引的设计:按照日期进行索引,或者按照月份进行索引,便于过期日志的清理
例如:projectName_Adapter_2021-01-21
新增模块
1.参考xxx-modules-system项目 2.修改bootstrap.yml配置文件
server:
port:(改成未被占用的新端口号)9301
spring:
application:
# 应用名称 改成新的模块名
name: ruoyi-demo
………………………………………其他不需要改……全复制过来即可………
···
3.修改nacos配置文件
然后登陆nacos后台,右侧点击配置管理->配置列表,新增配置ruoyi-demo-dev.yml
配置类型选择yaml
内容可复制其他配置内容把节点名改成ruoyi-demo > 4.网关的配置中新增路由节点
# 测试模块-------------------------这个节点是新增的这是路由配置
- id: ruoyi-demo
uri: lb://ruoyi-demo
predicates:
- Path=/test/**
filters:
- StripPrefix=1
6.在xxx-common-core项目中的ServiceNameConstants类中增加服务id