提交 f696b9dc 编写于 作者: 智布道's avatar 智布道 👁

🔧 增加 oneblog version 参数,能显示当前使用的版本

上级 a0f16c0d
......@@ -2,6 +2,7 @@ package com.zyd.blog.framework.config;
import com.jagregory.shiro.freemarker.ShiroTags;
import com.zyd.blog.business.service.SysConfigService;
import com.zyd.blog.framework.property.AppProperties;
import com.zyd.blog.framework.tag.ArticleTags;
import com.zyd.blog.framework.tag.CustomTags;
import freemarker.template.TemplateModelException;
......@@ -29,6 +30,8 @@ public class FreeMarkerConfig {
protected ArticleTags articleTags;
@Autowired
private SysConfigService configService;
@Autowired
private AppProperties appProperties;
/**
* 添加自定义标签
......@@ -39,6 +42,7 @@ public class FreeMarkerConfig {
configuration.setSharedVariable("articleTag", articleTags);
try {
configuration.setSharedVariable("config", configService.getConfigs());
configuration.setSharedVariable("appInfo", appProperties);
//shiro标签
configuration.setSharedVariable("shiro", new ShiroTags());
} catch (TemplateModelException e) {
......
......@@ -19,6 +19,23 @@ public class AppProperties {
/**
* 是否启用验证码
*/
public boolean enableKaptcha = false;
private boolean enableKaptcha = false;
/**
* 是否在项目启动时,打印配置文件中的 【数据库配置】,包括 mysql、redis,默认关闭,生产环境不建议开启
*/
private boolean enabledPrintConfig;
/**
* 是否启用 redis 切面缓存。
* <p>
* 优先级高于 {@link com.zyd.blog.business.annotation.RedisCache#enable()} 配置
*/
private boolean enableRedisCache;
/**
* 系统版本,不建议修改。有 OneBlog 作者定时更新
*/
private String version;
}
package com.zyd.blog.framework.runner;
import com.zyd.blog.framework.property.AppProperties;
import com.zyd.blog.framework.property.RedisProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,10 +31,8 @@ public class BlogApplicationRunner extends ContextLoaderListener implements Appl
@Value("${server.port}")
private int port;
@Value("${spring.profiles.active}")
private String profile;
@Value("${app.enabledConfigLog}")
private Boolean enabledConfigLog;
@Autowired
private AppProperties appProperties;
@Autowired
private DataSourceProperties dataSourceProperties;
......@@ -50,8 +49,9 @@ public class BlogApplicationRunner extends ContextLoaderListener implements Appl
@Override
public void contextInitialized(ServletContextEvent event) {
if (null != enabledConfigLog && enabledConfigLog) {
log.info("博客关键配置信息:");
log.info("博客关键配置信息:");
log.info("current version:{}", appProperties.getVersion());
if (appProperties.isEnabledConfigLog()) {
String[] activeProfiles = configurableApplicationContext.getEnvironment().getActiveProfiles();
if (ObjectUtils.isEmpty(activeProfiles)) {
String[] defaultProfiles = configurableApplicationContext.getEnvironment().getDefaultProfiles();
......
spring:
####### database Config #######
datasource:
druid:
connection-init-sqls: set names utf8mb4
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://${ONEBLOG_DATASOURCE_HOST:127.0.0.1}:${ONEBLOG_DATASOURCE_PORT:3306}/${ONEBLOG_DATASOURCE_DATABASE_NAME:dblog}?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true
username: ${ONEBLOG_DATASOURCE_USERNAME:root}
password: ${ONEBLOG_DATASOURCE_PASSWORD:root}
####### Redis Config #######
redis:
database: ${ONEBLOG_REDIS_DATABASE_INDEX:1}
# Redis服务器地址
host: ${ONEBLOG_REDIS_HOST:127.0.0.1}
# Redis服务器连接端口
port: ${ONEBLOG_REDIS_PORT:6379}
# Redis服务器连接密码(默认为空)
password: ${ONEBLOG_REDIS_PASSWORD:123456ZHYD}
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
####### redis缓存服务配置 #######
session:
store-type: redis
# 指定默认MimeMessage的编码,默认为: UTF-8
mail:
default-encoding: UTF-8
......@@ -24,19 +61,7 @@ spring:
mail.smtp.connectiontimeout: 50000
mail.smtp.timeout: 30000
mail.smtp.writetimeout: 50000
# Redis数据库索引(默认为0)
redis:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)
timeout: 5000ms
# 默认的数据过期时间,主要用于shiro权限管理
expire: 2592000
app:
version: v2.2.7
enableRedisCache: false
......@@ -131,7 +131,7 @@
<div class="container">
<div class="row">
<div class="col col-xs-12 col-md-12 col-lg-12">
<p><#if config.copyright!>${config.copyright} |</#if> Powered by <a href="https://gitee.com/yadong.zhang/DBlog" title="OneBlog是一款简洁美观、自适应的Java博客系统..." data-toggle="tooltip" data-placement="right" target="_blank"><i>OneBlog</i></a> </p>
<p><#if config.copyright!>${config.copyright} |</#if> Powered by <a href="https://gitee.com/yadong.zhang/DBlog" title="OneBlog是一款简洁美观、自适应的Java博客系统..." data-toggle="tooltip" data-placement="right" target="_blank" style="color: #4286ca;font-weight: 600;">OneBlog ${appInfo.version!}</a> </p>
<#if url?? && (url == "index")>
<div class="inline external-links">
<a>友情链接:</a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册