mirror of
https://gitee.com/blossom-editor/blossom.git
synced 2025-12-06 08:48:29 +08:00
feat: 指定应用的时区
This commit is contained in:
parent
10fc6d7f26
commit
9ae8778ab2
@ -15,6 +15,7 @@ import javax.sql.DataSource;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* 启动检查配置文件内容, 用于检查配置项是否正确
|
||||
@ -34,6 +35,7 @@ public class PropertiesCheckListener implements ApplicationListener<ApplicationE
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
|
||||
ConfigurableEnvironment env = event.getEnvironment();
|
||||
setTimeZone(env);
|
||||
log.warn("\n\n正在检查 Blossom 后台配置项\n\n" +
|
||||
"\n[CHECK] ==========================================================================================================================" +
|
||||
"\n[CHECK] 使用环境: [{}], 版本: [{}]" +
|
||||
@ -46,6 +48,7 @@ public class PropertiesCheckListener implements ApplicationListener<ApplicationE
|
||||
"\n[CHECK] 文件大小: {}" +
|
||||
"\n[CHECK] 授权时长: {}" +
|
||||
"\n[CHECK] 重置密码: {}" +
|
||||
"\n[CHECK] 指定时区: {}" +
|
||||
"\n[CHECK] ==========================================================================================================================\n\n",
|
||||
get(env, SpringUtil.PROFILE_ACTION), get(env, "project.base.version"),
|
||||
get(env, "spring.datasource.url"),
|
||||
@ -55,7 +58,8 @@ public class PropertiesCheckListener implements ApplicationListener<ApplicationE
|
||||
get(env, "project.iaas.blos.default-path"),
|
||||
get(env, "spring.servlet.multipart.max-file-size"),
|
||||
get(env, "project.auth.clients[0].duration"),
|
||||
get(env, "project.auth.password-reset")
|
||||
get(env, "project.auth.password-reset"),
|
||||
get(env, "project.base.time-zone")
|
||||
);
|
||||
|
||||
String defaultPath = get(env, "project.iaas.blos.default-path");
|
||||
@ -167,4 +171,15 @@ public class PropertiesCheckListener implements ApplicationListener<ApplicationE
|
||||
public boolean isNotReceived(String message) {
|
||||
return message.contains("The driver has not received any packets from the server");
|
||||
}
|
||||
|
||||
private void setTimeZone(ConfigurableEnvironment env) {
|
||||
String timeZone = get(env, "project.base.time-zone");
|
||||
if (StrUtil.isBlank(timeZone) || TimeZone.getTimeZone(timeZone) == null) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
|
||||
} else {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.31.99:3306/xzzz-blossom?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&allowMultiQueries=true&useSSL=false&&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://localhost:3306/blossom?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&allowMultiQueries=true&useSSL=false&&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: jasmine888
|
||||
hikari:
|
||||
@ -29,6 +29,7 @@ logging:
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ project ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
project:
|
||||
base:
|
||||
time-zone: GMT+8
|
||||
version: @project.version@
|
||||
ex:
|
||||
# 异常打印格式 all/project
|
||||
@ -51,7 +52,7 @@ project:
|
||||
type: caffeine
|
||||
default-password: 123456 # 默认密码
|
||||
password-encoder: bcrypt # 加密方式
|
||||
password-reset: false # 启动时重置密码
|
||||
password-reset: true # 启动时重置密码
|
||||
clients: # 客户端
|
||||
- client-id: blossom
|
||||
grant-type: 'password'
|
||||
|
||||
@ -20,6 +20,7 @@ logging:
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ project ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
project:
|
||||
base:
|
||||
time-zone: GMT+8
|
||||
version: @project.version@
|
||||
ex:
|
||||
# 异常打印格式 all/project
|
||||
|
||||
@ -23,6 +23,7 @@ logging:
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ project ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
project:
|
||||
base:
|
||||
time-zone: GMT+8
|
||||
version: @project.version@
|
||||
ex:
|
||||
# 异常打印格式 all/project
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.blossom.common.base;
|
||||
|
||||
import com.blossom.common.base.util.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@ -22,7 +23,7 @@ public final class BaseConstants {
|
||||
public static void desc() {
|
||||
log.info("启动完成" +
|
||||
"\n=========================================================================" +
|
||||
"\n启动成功: 可使用客户端登录, 默认用户名/密码: blos/blos" +
|
||||
"\n启动成功 [" + DateUtils.now() + "], 可使用客户端登录, 默认用户名/密码: blos/blos" +
|
||||
"\n下载地址: https://github.com/blossom-editor/blossom/releases" +
|
||||
"\n文档地址: https://www.wangyunf.com/blossom-doc/index" +
|
||||
"\n博客端访问地址: http://IP:端口(域名)/blog/#/home" +
|
||||
|
||||
@ -17,6 +17,11 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConfigurationProperties(prefix = "project.base")
|
||||
public class BaseProperties {
|
||||
|
||||
/**
|
||||
* 指定项目的时区
|
||||
*/
|
||||
private String timeZone = "GMT+8";
|
||||
|
||||
/**
|
||||
* 系统版本, 可以使用 @project.version@ 获取 pom 中版本
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user