mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-02 08:35:25 +08:00
Merge remote-tracking branch 'origin/master' into springboot3
# Conflicts: # jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java # jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/UndertowCustomizer.java # jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysFilesController.java # jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/entity/SysFiles.java
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
package org.jeecg;
|
||||
|
||||
import com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* 单体启动类
|
||||
* 报错提醒: 未集成mongo报错,可以打开启动类上面的注释 exclude={MongoAutoConfiguration.class}
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@ImportAutoConfiguration(JustAuthAutoConfiguration.class) // spring boot 3.x justauth 兼容性处理
|
||||
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
|
||||
public class JeecgSystemApplication extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(JeecgSystemApplication.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jeecg.codegenerate;
|
||||
|
||||
import org.jeecgframework.codegenerate.window.CodeWindow;
|
||||
|
||||
/**
|
||||
* @Title: 单表代码生成器入口
|
||||
* 【 GUI模式功能弱一些,请优先使用Online代码生成 】
|
||||
* @Author 张代浩
|
||||
* @site www.jeecg.com
|
||||
* @Version:V1.0.1
|
||||
*/
|
||||
public class JeecgOneGUI {
|
||||
|
||||
/** 使用手册: https://help.jeecg.com/vue3/codegen/gui.html */
|
||||
public static void main(String[] args) {
|
||||
new CodeWindow().pack();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package org.jeecg.codegenerate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecgframework.codegenerate.generate.impl.CodeGenerateOneToMany;
|
||||
import org.jeecgframework.codegenerate.generate.pojo.onetomany.MainTableVo;
|
||||
import org.jeecgframework.codegenerate.generate.pojo.onetomany.SubTableVo;
|
||||
|
||||
/**
|
||||
* 代码生成器入口【一对多】
|
||||
*
|
||||
* 【 GUI模式功能弱一些,请优先使用Online代码生成 】
|
||||
* @Author 张代浩
|
||||
* @site www.jeecg.com
|
||||
*
|
||||
*/
|
||||
public class JeecgOneToMainUtil {
|
||||
|
||||
/**
|
||||
* 一对多(父子表)数据模型,生成方法
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
//第一步:设置主表配置
|
||||
MainTableVo mainTable = new MainTableVo();
|
||||
//表名
|
||||
mainTable.setTableName("jeecg_order_main");
|
||||
//实体名
|
||||
mainTable.setEntityName("GuiTestOrderMain");
|
||||
//包名
|
||||
mainTable.setEntityPackage("gui");
|
||||
//描述
|
||||
mainTable.setFtlDescription("GUI订单管理");
|
||||
|
||||
//第二步:设置子表集合配置
|
||||
List<SubTableVo> subTables = new ArrayList<SubTableVo>();
|
||||
//[1].子表一
|
||||
SubTableVo po = new SubTableVo();
|
||||
//表名
|
||||
po.setTableName("jeecg_order_customer");
|
||||
//实体名
|
||||
po.setEntityName("GuiTestOrderCustom");
|
||||
//包名
|
||||
po.setEntityPackage("gui");
|
||||
//描述
|
||||
po.setFtlDescription("客户明细");
|
||||
//子表外键参数配置
|
||||
/*说明:
|
||||
* a) 子表引用主表主键ID作为外键,外键字段必须以_ID结尾;
|
||||
* b) 主表和子表的外键字段名字,必须相同(除主键ID外);
|
||||
* c) 多个外键字段,采用逗号分隔;
|
||||
*/
|
||||
po.setForeignKeys(new String[]{"order_id"});
|
||||
subTables.add(po);
|
||||
//[2].子表二
|
||||
SubTableVo po2 = new SubTableVo();
|
||||
//表名
|
||||
po2.setTableName("jeecg_order_ticket");
|
||||
//实体名
|
||||
po2.setEntityName("GuiTestOrderTicket");
|
||||
//包名
|
||||
po2.setEntityPackage("gui");
|
||||
//描述
|
||||
po2.setFtlDescription("产品明细");
|
||||
//子表外键参数配置
|
||||
/*说明:
|
||||
* a) 子表引用主表主键ID作为外键,外键字段必须以_ID结尾;
|
||||
* b) 主表和子表的外键字段名字,必须相同(除主键ID外);
|
||||
* c) 多个外键字段,采用逗号分隔;
|
||||
*/
|
||||
po2.setForeignKeys(new String[]{"order_id"});
|
||||
subTables.add(po2);
|
||||
mainTable.setSubTables(subTables);
|
||||
|
||||
//第三步:一对多(父子表)数据模型,代码生成
|
||||
try {
|
||||
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package org.jeecg.config.flyway;
|
||||
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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,实现了数据库版本自动升级! 其他类型的数据库,您可以考虑手工升级~");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user