Merge branch 'master' into springboot3

# Conflicts:
#	db/tables_nacos.sql
#	jeecg-boot-base-core/pom.xml
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger2Config.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysFilesController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleIndexController.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/entity/SysFiles.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java
#	jeecg-module-system/jeecg-system-start/pom.xml
#	jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
#	jeecg-server-cloud/jeecg-cloud-gateway/pom.xml
#	jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/pom.xml
#	pom.xml
This commit is contained in:
EightMonth
2024-03-25 09:39:13 +08:00
159 changed files with 22885 additions and 16825 deletions

View File

@ -0,0 +1,136 @@
package org.jeecg.config.flyway;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import lombok.extern.slf4j.Slf4j;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.FlywayException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import javax.sql.DataSource;
import java.util.Map;
/**
* @Description: 初始化flyway配置 修改之后支持多数据源,当出现异常时打印日志,不影响项目启动
*
* @author: wangshuai
* @date: 2024/3/12 10:03
*/
@Slf4j
@Configuration
public class FlywayConfig {
@Autowired
private DataSource dataSource;
@Autowired
private Environment environment;
/**
* 是否开启flyway
*/
@Value("${spring.flyway.enabled:false}")
private Boolean enabled;
/**
* 编码格式默认UTF-8
*/
@Value("${spring.flyway.encoding:UTF-8}")
private String encoding;
/**
* 迁移sql脚本文件存放路径官方默认db/migration
*/
@Value("${spring.flyway.locations:}")
private String locations;
/**
* 迁移sql脚本文件名称的前缀默认V
*/
@Value("${spring.flyway.sql-migration-prefix:V}")
private String sqlMigrationPrefix;
/**
* 迁移sql脚本文件名称的分隔符默认2个下划线__
*/
@Value("${spring.flyway.sql-migration-separator:__}")
private String sqlMigrationSeparator;
/**
* 文本前缀
*/
@Value("${spring.flyway.placeholder-prefix:#(}")
private String placeholderPrefix;
/**
* 文本后缀
*/
@Value("${spring.flyway.placeholder-suffix:)}")
private String placeholderSuffix;
/**
* 迁移sql脚本文件名称的后缀
*/
@Value("${spring.flyway.sql-migration-suffixes:.sql}")
private String sqlMigrationSuffixes;
/**
* 迁移时是否进行校验默认true
*/
@Value("${spring.flyway.validate-on-migrate:true}")
private Boolean validateOnMigrate;
/**
* 当迁移发现数据库非空且存在没有元数据的表时自动执行基准迁移新建schema_version表
*/
@Value("${spring.flyway.baseline-on-migrate:true}")
private Boolean baselineOnMigrate;
/**
* 是否关闭要清除已有库下的表功能,生产环境必须为true,否则会删库,非常重要!!!
*/
@Value("${spring.flyway.clean-disabled:true}")
private Boolean cleanDisabled;
@Bean
public void migrate() {
if(!enabled){
return;
}
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
Map<String, DataSource> dataSources = ds.getDataSources();
dataSources.forEach((k, v) -> {
if("master".equals(k)){
String databaseType = environment.getProperty("spring.datasource.dynamic.datasource." + k + ".url");
if (databaseType != null && databaseType.contains("mysql")) {
try {
Flyway flyway = Flyway.configure()
.dataSource(v)
.locations(locations)
.encoding(encoding)
.sqlMigrationPrefix(sqlMigrationPrefix)
.sqlMigrationSeparator(sqlMigrationSeparator)
.placeholderPrefix(placeholderPrefix)
.placeholderSuffix(placeholderSuffix)
.sqlMigrationSuffixes(sqlMigrationSuffixes)
.validateOnMigrate(validateOnMigrate)
.baselineOnMigrate(baselineOnMigrate)
.cleanDisabled(cleanDisabled)
.load();
flyway.migrate();
log.info("【升级提示】平台集成了MySQL库的Flyway数据库版本自动升级! ");
} catch (FlywayException e) {
log.error("【升级提示】flyway执行sql脚本失败", e);
}
} else {
log.warn("【升级提示】平台只集成了MySQL库的Flyway实现了数据库版本自动升级! 其他类型的数据库,您可以考虑手工升级~");
}
}
});
}
}

View File

@ -123,7 +123,9 @@ spring:
resource:
static-locations: classpath:/static/,classpath:/public/
autoconfigure:
exclude: com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure
exclude:
- com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure
- org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration
datasource:
druid:
stat-view-servlet:
@ -139,7 +141,7 @@ spring:
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
maxActive: 20
maxActive: 1000
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
@ -177,7 +179,7 @@ spring:
database: 0
host: 127.0.0.1
port: 6379
password:
password:
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
@ -264,9 +266,23 @@ jeecg:
#分布式锁配置
redisson:
address: 127.0.0.1:6379
password:
password:
type: STANDALONE
enabled: true
# ai-chat
ai-chat:
# 是否开启;必须。
enabled: false
# openAi接口秘钥填写自己的apiKey必须。
apiKey: ""
# openAi域名有代理就填代理的域名。默认openAI官方apiHost
apiHost: "https://api.openai.com"
# 超时时间单位:s。默认 60s
timeout: 60
# 本地代理地址
# proxy:
# host: "http://127.0.0.1"
# port: "7890"
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas

View File

@ -123,7 +123,9 @@ spring:
resource:
static-locations: classpath:/static/,classpath:/public/
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
- org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration
datasource:
druid:
stat-view-servlet:
@ -273,6 +275,7 @@ cas:
#Mybatis输出sql日志
logging:
level:
org.flywaydb: debug
org.jeecg.modules.system.mapper: info
#swagger
knife4j:

View File

@ -28,7 +28,7 @@ spring:
# flyway配置
flyway:
# 是否启用flyway
enabled: true
enabled: false
# 编码格式默认UTF-8
encoding: UTF-8
# 迁移sql脚本文件存放路径官方默认db/migration
@ -123,7 +123,9 @@ spring:
resource:
static-locations: classpath:/static/,classpath:/public/
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
exclude:
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
- org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration
datasource:
druid:
stat-view-servlet:
@ -139,7 +141,7 @@ spring:
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
maxActive: 20
maxActive: 1000
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒

View File

@ -9,7 +9,7 @@ ${AnsiColor.BRIGHT_BLUE}
${AnsiColor.BRIGHT_GREEN}
Jeecg Boot Version: 3.6.2
Jeecg Boot Version: 3.6.3
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
产品官网: www.jeecg.com
版权所属: 北京国炬信息技术有限公司

View File

@ -0,0 +1,18 @@
# SQL文件命名规则
`V[年月日]_[序号]__[模块名缩写]_[操作类型]_[业务描述].sql`
例如:
```
V20240104_1__easyoa_add_field_attendance.sql
R__202402_drag_update_template.sql
```
### SQL命名规则说明
- 1.仅需要执行一次的以大写“V”开头
- 2.需要执行多次的以大写“R”开头命名如R__clean.sqlR的脚本只要改变了就会执行
- 3.V开头的比R开头的优先级要高。
### 命名规则示例
参考博客:
https://blog.csdn.net/Jiao1225/article/details/129590660

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,7 @@ database_name=jeecg-boot
#username=postgres
#password=postgres
#database_name=jeecg
#schemaName=public
#SQLServer2005\u4ee5\u4e0a
#diver_name=org.hibernate.dialect.SQLServerDialect