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