add banner print

This commit is contained in:
开源海哥 2023-04-22 11:27:05 +08:00
parent 42f3ecc016
commit 4a016cc893
3 changed files with 29 additions and 1 deletions

View File

@ -31,6 +31,11 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class FlexGlobalConfig {
/**
* 启动是否打印 banner 版本好
*/
private boolean printBanner = true;
/**
* 默认使用 Mysql 数据库类型
*/
@ -66,6 +71,13 @@ public class FlexGlobalConfig {
private Object normalValueOfLogicDelete = FlexConsts.LOGIC_DELETE_NORMAL;
private Object deletedValueOfLogicDelete = FlexConsts.LOGIC_DELETE_DELETED;
public boolean isPrintBanner() {
return printBanner;
}
public void setPrintBanner(boolean printBanner) {
this.printBanner = printBanner;
}
public DbType getDbType() {
return dbType;

View File

@ -62,6 +62,7 @@ public class FlexConfiguration extends Configuration {
initDefaultMappers();
}
/**
* 设置 mybatis-flex 默认的 Mapper
* 当前只有 RowMapper {@link RowMapper}

View File

@ -15,6 +15,7 @@
*/
package com.mybatisflex.core.mybatis;
import com.mybatisflex.core.FlexConsts;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.dialect.DbType;
import com.mybatisflex.core.dialect.DbTypeUtil;
@ -63,10 +64,25 @@ public class FlexSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
//设置全局配置的 sessionFactory dbType
initGlobalConfig(configuration, sessionFactory, dbType);
printBanner();
return sessionFactory;
}
private void printBanner() {
if (!FlexGlobalConfig.getDefaultConfig().isPrintBanner()) {
return;
}
String banner = " __ __ _ _ _ _____ _ \n" +
" | \\/ |_ _| |__ __ _| |_(_)___ | ___| | _____ __\n" +
" | |\\/| | | | | '_ \\ / _` | __| / __| | |_ | |/ _ \\ \\/ /\n" +
" | | | | |_| | |_) | (_| | |_| \\__ \\ | _| | | __/> < \n" +
" |_| |_|\\__, |_.__/ \\__,_|\\__|_|___/ |_| |_|\\___/_/\\_\\\n" +
" |___/ v" + FlexConsts.VERSION + " https://mybatis-flex.com";
System.out.println(banner);
}
/**
* 设置全局配置
*
@ -84,5 +100,4 @@ public class FlexSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
}
}