...
 
Commits (18)
    https://gitcode.net/u011197448/oneblog/-/commit/d62c0d5708d9fa6c11b97346ce425b8271a31a3a :hankey: 修改 docker 参数 ONEBLOG_APP_ENABLE_CONFIGLOG 为 ONEBLOG_APP_ENABLE_PRINT... 2021-08-27T19:57:42+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/3b8a56c760ee9f3ef8b03b3309a98ade993b6c1a :bookmark: 更新 oneblog 版本 2021-08-27T19:58:13+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/cecbd8530f741b9130ca47f9431a4d788465b1e2 :see_no_evil: 更新 .gitignore 文件 2021-08-27T19:58:45+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/3721cd85a1bc44adfe18060501530f697d08e665 :wrench: 修改配置文件,删除 application-center-dev.yml 2021-08-27T19:59:08+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/a0f16c0d52d1d59a51880b80fb62d1c212e01442 :wrench: 将 enabledConfigLog 更名为 enabledPrintConfig,更加语义化 2021-08-27T19:59:55+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/f696b9dc6460bec223feae8c3383627c8b0dcef1 :wrench: 增加 oneblog version 参数,能显示当前使用的版本 2021-08-27T20:00:28+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/84e4bfbcf898ea2671af5725ed1ede4ae377fc68 :hankey: 增加 enableRedisCache 参数,可以动态开启 redis 切面缓存,开发环境可以关闭该配置,方便调试 2021-08-27T20:02:19+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/ed07dac208074148706d2c30508455f85151a4b5 :hankey: 2021-08-27T20:02:59+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/4b5567a6f24a9a41a704b61dbfe1e41db51a1168 Merge branch 'master' of github.com:zhangyd-c/OneBlog 2021-08-27T21:57:20+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/9428c00003b7a917492719916891787485f2662f :hankey: Github PR [#18] 2021-08-27T21:59:15+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/77081f4b2a1bf0e3e87625f20e0eaaa260395dd9 :arrow_up: springboot 升级到 2.3.4.RELEASE 2021-08-29T18:17:57+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/ef2d36741aab85f4b9899fc6da55b3db1a654f32 :hankey: 添加系统版本 2021-08-29T20:56:28+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/6cc0bcd734609c779e7e05b4d7fb4f2abc8e5ef8 :hankey: 调整原创/转载角标的样式 2021-08-29T20:56:49+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/33e1ab0a1f5e3853597481caeda1840692ba7de1 :hankey: 查询文章关联获取type时加上icon 2021-08-29T20:57:17+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/c170ab84217e768d2c69b44768709b4228bcd266 :hankey: 调整原创/转载角标的样式 2021-08-29T20:57:29+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/f9ba4071f39187f962ffbf75275846482df9f6c4 :hankey: 调整样式 2021-08-29T20:57:40+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/0a8cb63deb3d792b98d8b8e092be89608e267658 :bookmark: 升级到 2.2.8 2021-08-29T22:02:43+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/3c5a1c00b48ec1b2861fa2b2ac843374325cb911 :memo: 修改使用说明 2021-08-29T22:20:15+08:00 yadong.zhang yadong.zhang0415@gmail.com
......@@ -21,4 +21,3 @@
hs_err_pid*
/.idea/
*.iml
/blog-core/src/main/resources/config/application-center-prod.yml
......@@ -81,8 +81,10 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
# 技术栈
- Springboot 2.0.8
- Apache Shiro 1.2.2
- docker
- docker-compose
- Springboot 2.3.4.RELEASE
- Apache Shiro 1.7.1
- Logback
- Redis
- Lombok
......@@ -91,10 +93,12 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
- Freemarker
- Bootstrap 3.3.0
- wangEditor
- Markdown
- jQuery 1.11.1、jQuery Lazyload 1.9.7、fancybox、iCheck
- 阿里云OSS
- 七牛云
- Nginx
- kaptcha
- Qiniu
- webMagic
- ...
......@@ -121,10 +125,7 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
2. 新建数据库`CREATE DATABASE dblog;`
3. 导入数据库`docs/docker/mysql/dblog.sql`
4. 初始化数据库`docs/docker/mysql/init_data.sql`
5. 修改配置文件
1. 数据库链接属性(在`[blog-core]/resources/config/application-center-{env}.yml`配置文件中搜索`datasource`或定位到L.5)
2. redis配置(在`[blog-core]/resources/config/application-center-{env}.yml`配置文件中搜索`redis`或定位到L.14)
3. 以上两个必备的配置项修改完成后就能启动项目了。关于其他配置项,请参考后台“系统配置”页面
5. 修改配置文件,mysql、redis、mail配置在`[blog-core]/resources/config/application-center.yml`配置文件中
6. 运行项目:直接运行 `blog-web/src/main/java/com/zyd/blog/BlogWebApplication.java` 或者 `blog-admin/src/main/java/com/zyd/blog/BlogAdminApplication.java`
7. 浏览器访问`http://127.0.0.1:{port}`
......
......@@ -12,7 +12,7 @@
<parent>
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</parent>
<dependencies>
......
......@@ -3,6 +3,7 @@ package com.zyd.blog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* 程序启动类
......@@ -15,6 +16,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
*/
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
public class BlogAdminApplication {
public static void main(String[] args) {
......
......@@ -13,6 +13,7 @@ public class MyClassResolvingObjectInputStream extends ObjectInputStream {
super(inputStream);
}
@Override
protected Class<?> resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
try {
String s = osc.getName();
......@@ -38,4 +39,4 @@ public class MyClassResolvingObjectInputStream extends ObjectInputStream {
throw new ClassNotFoundException("Unable to load ObjectStreamClass [" + osc + "]: ", var3);
}
}
}
\ No newline at end of file
}
......@@ -9,6 +9,7 @@ public class MySecSerializer<T> implements Serializer<T> {
public MySecSerializer() {
}
@Override
public byte[] serialize(T o) throws SerializationException {
if (o == null) {
String msg = "argument cannot be null.";
......@@ -29,6 +30,7 @@ public class MySecSerializer<T> implements Serializer<T> {
}
}
@Override
public T deserialize(byte[] serialized) throws SerializationException {
if (serialized == null) {
String msg = "argument cannot be null.";
......
......@@ -5,12 +5,13 @@ server:
# SPRING PROFILES
spring:
profiles:
include: [center-dev]
include: [center]
# logging settings
logging:
config: classpath:logback-spring.xml
path: /var/tmp/oneblog/blog-admin
file:
path: /var/tmp/oneblog/blog-admin
####################################自定义配置##########################################
app:
......@@ -18,7 +19,7 @@ app:
enableKaptcha: ${ONEBLOG_APP_ENABLE_KAPTCHA:false}
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: ${ONEBLOG_APP_ENABLE_CONFIGLOG:false}
enabledPrintConfig: ${ONEBLOG_APP_ENABLE_PRINT_CONFIG:false}
# shiro配置项
shiro:
loginUrl: "/passport/login/"
......
......@@ -3,16 +3,21 @@ server:
port: 8085
# HTTP请求和响应头的最大量,以字节为单位,默认值为4096字节,超过此长度的部分不予处理,一般8K。解决java.io.EOFException: null问题
max-http-header-size: 8192
use-forward-headers: true
compression:
enabled: true
min-response-size: 1024
mime-types: text/plain,text/css,text/xml,text/javascript,application/json,application/javascript,application/xml,application/xml+rss,application/x-javascript,application/x-httpd-php,image/jpeg,image/gif,image/png
tomcat:
remote-ip-header: X-Forwarded-for
protocol-header: X-Forwarded-Proto
port-header: X-Forwarded-Port
remoteip:
remote-ip-header: X-Forwarded-for
protocol-header: X-Forwarded-Proto
port-header: X-Forwarded-Port
uri-encoding: UTF-8
servlet:
encoding:
enabled: true
force: true
force-response: true
# SPRING PROFILES
spring:
profiles:
......@@ -42,11 +47,6 @@ spring:
multipart:
max-file-size: 50MB
max-request-size: 50MB
http:
encoding:
enabled: true
charset: UTF-8
force: true
messages:
encoding: UTF-8
jmx:
......@@ -60,19 +60,3 @@ spring:
paths: /**
banner:
charset: UTF-8
# MyBatis
mybatis:
type-aliases-package: com.zyd.blog.persistence.beans
mapper-locations: classpath:/mybatis/*.xml
# mapper
mapper:
mappers:
- com.zyd.blog.plugin.BaseMapper
not-empty: false
identity: MYSQL
# pagehelper
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
\ No newline at end of file
......@@ -29,6 +29,7 @@
<logger name="org.springframework.core.env" level="DEBUG"/>
<logger name="us.codecraft.webmagic.downloader" level="DEBUG"/>
<logger name="com.zyd.blog.framework.runner" level="DEBUG"/>
<logger name="org.crazycake.shiro.RedisCache" level="INFO"/>
<!-- 测试环境+开发环境,日志级别为INFO且不写日志文件 -->
<springProfile name="dev">
......
......@@ -12,7 +12,7 @@
<parent>
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</parent>
<dependencies>
......@@ -59,24 +59,12 @@
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--mapper-->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>${mapper.version}</version>
<exclusions>
<exclusion>
<artifactId>mybatis-spring-boot-starter</artifactId>
<groupId>org.mybatis.spring.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!--pagehelper-->
<dependency>
......@@ -88,7 +76,6 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--druid依赖添加-->
<dependency>
......@@ -136,6 +123,46 @@
<artifactId>shiro-core</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-cache</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-config-core</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-config-ogdl</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-crypto-cipher</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-lang</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-crypto-hash</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-event</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-spring</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>shiro-web</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 解析HTML -->
......@@ -168,11 +195,6 @@
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>me.zhyd.hunter</groupId>
<artifactId>blog-hunter</artifactId>
......@@ -191,16 +213,20 @@
<artifactId>jsoup</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-el-api</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper-el</artifactId>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<artifactId>commons-collections</artifactId>
<groupId>commons-collections</groupId>
</exclusion>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
......@@ -217,7 +243,7 @@
<dependency>
<artifactId>okhttp</artifactId>
<groupId>com.squareup.okhttp3</groupId>
<version>4.5.0</version>
<version>4.9.1</version>
</dependency>
<dependency>
......@@ -229,6 +255,12 @@
<groupId>com.fujieid</groupId>
<artifactId>jap-social</artifactId>
<version>${jap.version}</version>
<exclusions>
<exclusion>
<artifactId>fastjson</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
......@@ -2,6 +2,7 @@ package com.zyd.blog.business.aspect;
import com.zyd.blog.business.annotation.RedisCache;
import com.zyd.blog.business.service.RedisService;
import com.zyd.blog.framework.property.AppProperties;
import com.zyd.blog.util.AspectUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -31,6 +32,8 @@ public class RedisCacheAspect {
@Autowired
private RedisService redisService;
@Autowired
private AppProperties appProperties;
@Pointcut(value = "@annotation(com.zyd.blog.business.annotation.RedisCache)")
public void pointcut() {
......@@ -38,6 +41,9 @@ public class RedisCacheAspect {
@Around("pointcut()")
public Object handle(ProceedingJoinPoint point) throws Throwable {
if (!appProperties.isEnableRedisCache()) {
return point.proceed();
}
Method currentMethod = AspectUtil.INSTANCE.getMethod(point);
//获取操作名称
RedisCache cache = currentMethod.getAnnotation(RedisCache.class);
......
......@@ -317,7 +317,6 @@ public class BizArticleServiceImpl implements BizArticleService {
@Override
public List<Article> listHotArticle(int pageSize) {
PageHelper.startPage(1, pageSize);
List<BizArticle> entityList = bizArticleMapper.listHotArticle();
if (CollectionUtils.isEmpty(entityList)) {
return null;
......
......@@ -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) {
......
package com.zyd.blog.framework.config;
import org.apache.catalina.valves.RemoteIpValve;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -13,17 +15,17 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
public class TomcatConfig {
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(
connector -> {
Http11NioProtocol protocol =
(Http11NioProtocol) connector.getProtocolHandler();
protocol.setDisableUploadTimeout(false);
}
);
return factory;
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
RemoteIpValve remoteIpValve = new RemoteIpValve();
// 下面这里的值要与nginx的header头对应
remoteIpValve.setRemoteIpHeader("X-Forwarded-For");
remoteIpValve.setProtocolHeader("X-Forwarded-Proto");
remoteIpValve.setProtocolHeaderHttpsValue("https");
tomcat.addEngineValves(remoteIpValve);
return tomcat;
}
......
......@@ -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.isEnabledPrintConfig()) {
String[] activeProfiles = configurableApplicationContext.getEnvironment().getActiveProfiles();
if (ObjectUtils.isEmpty(activeProfiles)) {
String[] defaultProfiles = configurableApplicationContext.getEnvironment().getDefaultProfiles();
......
......@@ -3,6 +3,7 @@ package com.zyd.blog.persistence.mapper;
import com.zyd.blog.business.vo.ArticleConditionVO;
import com.zyd.blog.persistence.beans.BizArticle;
import com.zyd.blog.plugin.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -16,7 +17,7 @@ import java.util.List;
* @date 2018/4/16 16:26
* @since 1.0
*/
@Repository
@Mapper
public interface BizArticleMapper extends BaseMapper<BizArticle> {
/**
......
spring:
profiles:
include: [center]
####### 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}
####### redis缓存服务配置 #######
session:
store-type: redis
spring:
####### database Config #######
datasource:
druid:
connection-init-sqls: set names utf8mb4
driver-class-name: com.mysql.cj.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}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false
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,30 @@ 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
# MyBatis
mybatis:
type-aliases-package: com.zyd.blog.persistence.beans
mapper-locations: classpath:/mybatis/*.xml
configuration:
default-enum-type-handler: org.apache.ibatis.type.EnumTypeHandler
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# mapper
mapper:
mappers:
- com.zyd.blog.plugin.BaseMapper
not-empty: false
identity: MYSQL
use-simple-type: false
enum-as-simple-type: true
# pagehelper
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
app:
version: v2.2.8
enableRedisCache: false
......@@ -29,6 +29,7 @@
<association property="bizType" javaType="com.zyd.blog.persistence.beans.BizType">
<result property="id" jdbcType="BIGINT" column="btype_id"/>
<result property="name" jdbcType="VARCHAR" column="btype_name"/>
<result property="icon" jdbcType="VARCHAR" column="btype_icon"/>
<result property="description" jdbcType="VARCHAR" column="btype_description"/>
</association>
<collection property="tags" column="tag_id" javaType="ArrayList" ofType="com.zyd.blog.persistence.beans.BizTags">
......@@ -59,6 +60,7 @@
a.update_time,
btype.id AS btype_id,
btype.`name` AS btype_name,
btype.`icon` AS btype_icon,
btype.description AS btype_description
FROM
biz_article a
......
......@@ -12,7 +12,7 @@
<parent>
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</parent>
<properties>
......
......@@ -23,4 +23,3 @@
/dist/
/nbdist/
/.nb-gradle/
/src/main/resources/application-prod.yml
......@@ -12,7 +12,7 @@
<parent>
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</parent>
<dependencies>
......
......@@ -28,7 +28,7 @@ public class ArticleLookTask {
private final BizArticleLookService articleLookService;
private BlockingQueue<ArticleLook> queue = new ArrayBlockingQueue<>(1024);
private final BlockingQueue<ArticleLook> queue = new ArrayBlockingQueue<>(1024);
/**
* 保存文章的浏览记录,先进先出
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.zyd.blog.core.schedule.ArticleLookTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
......@@ -21,8 +20,6 @@ import java.util.concurrent.*;
@Component
public class TaskRunner implements ApplicationRunner {
@Value("${server.port}")
private int port;
@Autowired
private ArticleLookTask articleLookTask;
......@@ -35,7 +32,7 @@ public class TaskRunner implements ApplicationRunner {
new LinkedBlockingQueue<Runnable>(1024),
articleLookThreadFactory, new ThreadPoolExecutor.AbortPolicy());
singleThreadPool.execute(()-> articleLookTask.save());
singleThreadPool.execute(() -> articleLookTask.save());
singleThreadPool.shutdown();
}
}
......@@ -5,12 +5,13 @@ server:
# SPRING PROFILES
spring:
profiles:
include: [center-dev]
include: [center]
# logging settings
logging:
config: classpath:logback-spring.xml
path: /var/tmp/oneblog/blog-web
file:
path: /var/tmp/oneblog/blog-web
# braum过滤器,用于过滤恶意请求
braum:
......@@ -26,5 +27,5 @@ app:
enableKaptcha: ${ONEBLOG_APP_ENABLE_KAPTCHA:false}
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
# 代码请参考
enabledConfigLog: ${ONEBLOG_APP_ENABLE_CONFIGLOG:false}
enabledPrintConfig: ${ONEBLOG_APP_ENABLE_PRINT_CONFIG:false}
####################################自定义配置##########################################
......@@ -3,20 +3,27 @@ server:
port: 8443
# HTTP请求和响应头的最大量,以字节为单位,默认值为4096字节,超过此长度的部分不予处理,一般8K。解决java.io.EOFException: null问题
max-http-header-size: 8192
use-forward-headers: true
compression:
enabled: true
min-response-size: 1024
mime-types: text/plain,text/css,text/xml,text/javascript,application/json,application/javascript,application/xml,application/xml+rss,application/x-javascript,application/x-httpd-php,image/jpeg,image/gif,image/png
tomcat:
remote-ip-header: X-Forwarded-for
protocol-header: X-Forwarded-Proto
port-header: X-Forwarded-Port
remoteip:
remote-ip-header: X-Forwarded-for
protocol-header: X-Forwarded-Proto
port-header: X-Forwarded-Port
uri-encoding: UTF-8
servlet:
encoding:
enabled: true
force: true
force-response: true
# SPRING PROFILES
spring:
profiles:
active: '@profileActive@'
main:
allow-bean-definition-overriding: true
application:
name: blog-web
freemarker:
......@@ -42,11 +49,6 @@ spring:
multipart:
max-file-size: 50MB
max-request-size: 50MB
http:
encoding:
enabled: true
charset: UTF-8
force: true
messages:
encoding: UTF-8
jmx:
......@@ -60,19 +62,3 @@ spring:
paths: /**
banner:
charset: UTF-8
# MyBatis
mybatis:
type-aliases-package: com.zyd.blog.persistence.beans
mapper-locations: classpath:/mybatis/*.xml
# mapper
mapper:
mappers:
- com.zyd.blog.plugin.BaseMapper
not-empty: false
identity: MYSQL
# pagehelper
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
\ No newline at end of file
......@@ -12,71 +12,38 @@
</appender>
<!--按天生成日志-->
<!-- 出错日志 appender -->
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logdir}/error.log</File>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${logdir}/error-%d{yyyy-MM-dd}.log
</fileNamePattern>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<FileNamePattern>
${logdir}/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%class:%line] %-5level - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印错误日志 -->
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- info日志 appender -->
<appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logdir}/info.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${logdir}/info-%d{yyyy-MM-dd}.log
</fileNamePattern>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%class:%line] %-5level - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印错误日志 -->
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
</Pattern>
</layout>
</appender>
<logger name="org.springframework.core.env" level="ERROR"/>
<logger name="com.zyd.blog.framework.runner" level="INFO"/>
<logger name="org.springframework.core.env" level="DEBUG"/>
<logger name="us.codecraft.webmagic.downloader" level="DEBUG"/>
<logger name="com.zyd.blog.framework.runner" level="DEBUG"/>
<logger name="org.crazycake.shiro.RedisCache" level="INFO"/>
<!-- 测试环境+开发环境,日志级别为INFO且不写日志文件 -->
<springProfile name="test,dev">
<logger name="com.zyd.blog" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<root level="INFO">
<springProfile name="dev">
<root level="DEDBUG">
<appender-ref ref="STDOUT"/>
</root>
</springProfile>
<!-- 生产环境. 日志级别为WARN且写日志文件-->
<springProfile name="prod">
<logger name="com.zyd.blog" additivity="false">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE_ERROR" />
<appender-ref ref="FILE_INFO" />
</logger>
<root level="WARN">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE_ERROR" />
<appender-ref ref="FILE_INFO" />
<appender-ref ref="FILE" />
</root>
</springProfile>
</configuration>
\ No newline at end of file
</configuration>
......@@ -492,32 +492,29 @@ a:-webkit-any-link {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
.article-blockquote-red {
background: #c40000;
.article-blockquote-gray {
background: #7a7a7a !important;
}
.article-blockquote-green {
background: #31d229;
.article-original-gray {
background: #999;
}
.article-original-red {
background: 0 0 rgba(216, 0, 0, 0.7);
.article-blockquote-green {
background: #427e53;
}
.article-original-green {
background: #31708f;
background: #5FB878;
}
.article-flag .article-original {
border-radius: 0;
padding: 0 10px;
padding: 0 5px;
line-height: 2.2;
display: block;
color: #fff;
position: absolute;
filter: alpha(opacity=70);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
margin-left: 10px;
margin-left: 4px;
}
.article-flag .article-original a {
......@@ -1136,18 +1133,29 @@ article .thumbnail a img {
max-width: 100%;
border: 0;
}
.art {
font-size: 12px;
display: inline-block;
line-height: 20px;
border-radius: 2px;
color: #fff;
padding: 0 5px;
position: inherit;
float: left;
margin-top: 7px;
margin-right: 6px;
}
.art-original {
background: #35b871;
}
.art-original-0 {
background: #999;
}
.art-top {
background: #e63946!important;
}
.art-type {
font-size: 12px;
display: inline-block;
line-height: 20px;
background: #5d5d5d;
border-radius: 2px;
color: #fff;
padding: 0 5px;
position: inherit;
float: left;
margin-top: 7px;
margin-right: 6px;
background: #999;
}
.art-type-yellow {
background: #fbd602!important;
......@@ -1181,7 +1189,7 @@ article header h2 {
article header h2 a {
color: #555 !important;
font-size: 20px;
font-size: 18px;
line-height: 24px;
font-weight: 700;
}
......@@ -3152,6 +3160,10 @@ nav a:first-child .meta-nav {
text-indent: 4em;
}
.site-desc {
padding: 0 8px;
}
.site-desc h1 {
font-size: 20px;
font-weight: 700;
......
......@@ -16,14 +16,14 @@
<div class="blog-body overflow-initial fade-in">
<div class="article-flag">
<#if article.original?string('true','false') == 'true'>
<span class="article-blockquote article-blockquote-red"></span>
<span class="article-original article-original-red">
<a href="${config.siteUrl}/article/${article.id}">原创</a>
<span class="article-blockquote article-blockquote-green"></span>
<span class="article-original article-original-green">
<a href="${config.siteUrl}/article/${article.id}"><i class="fa fa-check"></i> 原创</a>
</span>
<#else>
<span class="article-blockquote article-blockquote-red"></span>
<span class="article-original article-original-red">
<a href="${config.siteUrl}/article/${article.id}">转载</a>
<span class="article-blockquote article-blockquote-gray"></span>
<span class="article-original article-original-gray">
<a href="${config.siteUrl}/article/${article.id}"><i class="fa fa-reply"></i> 转载</a>
</span>
</#if>
<div class="blog-info-meta pull-right">
......
......@@ -16,7 +16,7 @@
<div class="bottom-line title"><i class="fa fa-question-circle-o"></i><strong>为什么会被限制?</strong></div>
<ol>
<li>1.快速的、频繁的、大量的刷新页面</li>
<li>2.疑是Spider</strong></li>
<li>2.疑是Spider</li>
<li>3.系统抽风</li>
</ol>
<div class="clear"></div>
......
......@@ -70,10 +70,18 @@
</figure>
</#if>
<header class="entry-header">
<#if item.original?string('true','false') == 'true'>
<span class="art art-original"><i class="fa fa-check fa-fw"></i>原创</span>
<#else>
<span class="art art-original-0"><i class="fa fa-reply fa-fw"></i>转载</span>
</#if>
<#if item.private>
<span class="art-type art-type-yellow"><i class="fa fa-lock fa-fw"></i>私密</span>
<span class="art art-type art-type-yellow"><i class="fa fa-lock fa-fw"></i>私密</span>
</#if>
<#if item.top>
<span class="art art-top"><i class="fa fa-chevron-circle-up fa-fw"></i>置顶</span>
</#if>
<span class="art-type"><a href="${config.siteUrl}/type/${item.typeId?c}">${item.type.name}</a></span>
<span class="art art-type"><a href="${config.siteUrl}/type/${item.typeId?c}"><i class="${item.type.icon!} fa-fw"></i> ${item.type.name}</a></span>
<h2 class="entry-title">
<a href="${config.siteUrl}/article/${item.id?c}" rel="bookmark" title="${item.title}" data-toggle="tooltip" data-placement="bottom">${item.title}</a>
</h2>
......
......@@ -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>
......
......@@ -174,6 +174,7 @@
<li> <i class="fa fa-users fa-fw"></i> 在线人数:<span class="online">1</span>人</li>
<li> <i class="fa fa-calendar fa-fw"></i> 运行天数:${siteInfo.installdate!(1)}天</li>
<li> <i class="fa fa-pencil-square fa-fw"></i> 最后更新:${siteInfo.lastUpdateTime!("暂无更新记录")}</li>
<li> <i class="fa fa-vine fa-fw"></i> 系统版本:<a href="https://gitee.com/yadong.zhang/DBlog/releases/${appInfo.version!}" rel="nofollow" target="_blank" style="color: #4286ca;font-weight: 600;">${appInfo.version!}</a></li>
</@zhydTag>
</ul>
</div>
......
......@@ -28,4 +28,4 @@ ONEBLOG_MAIL_PASSWORD=
# 是否启用kaptcha验证码
ONEBLOG_APP_ENABLE_KAPTCHA=false
# 启用后,项目在启动时会打印数据库(Mysql和Redis)链接信息(包含密码)
ONEBLOG_APP_ENABLE_CONFIGLOG=true
ONEBLOG_APP_ENABLE_PRINT_CONFIG=true
......@@ -63,7 +63,7 @@ services:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
ONEBLOG_APP_ENABLE_PRINT_CONFIG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
......@@ -100,7 +100,7 @@ services:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
ONEBLOG_APP_ENABLE_PRINT_CONFIG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
......
......@@ -65,7 +65,7 @@ services:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
ONEBLOG_APP_ENABLE_PRINT_CONFIG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
......@@ -103,7 +103,7 @@ services:
ONEBLOG_MAIL_USERNAME:
ONEBLOG_MAIL_PASSWORD:
ONEBLOG_APP_ENABLE_KAPTCHA:
ONEBLOG_APP_ENABLE_CONFIGLOG:
ONEBLOG_APP_ENABLE_PRINT_CONFIG:
volumes:
- ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
depends_on:
......
......@@ -5,7 +5,7 @@
<groupId>com.zyd</groupId>
<artifactId>blog</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
<packaging>pom</packaging>
<modules>
<module>blog-core</module>
......@@ -20,37 +20,38 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.8.RELEASE</version>
<version>2.3.4.RELEASE</version>
<relativePath/>
</parent>
<properties>
<oneblog.version>2.2.8</oneblog.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
<webmagic.version>0.7.3</webmagic.version>
<jsoup.version>1.10.2</jsoup.version>
<jsoup.version>1.14.2</jsoup.version>
<javax.validation.version>2.0.1.Final</javax.validation.version>
<hibernate.validator.version>6.0.9.Final</hibernate.validator.version>
<tomcat.version>8.5.57</tomcat.version>
<hibernate.validator.version>7.0.1.Final</hibernate.validator.version>
<excel4j.version>2.1.4-Final</excel4j.version>
<mybatis.version>2.1.4</mybatis.version>
<mapper.version>2.1.5</mapper.version>
<pagehelper.version>1.3.0</pagehelper.version>
<druid.version>1.1.10</druid.version>
<fastjson.version>1.2.76</fastjson.version>
<druid.version>1.2.6</druid.version>
<fastjson.version>1.2.78</fastjson.version>
<shiro.spring.version>1.7.1</shiro.spring.version>
<shiro.redis.version>2.4.2.1-RELEASE</shiro.redis.version>
<shiro.freemarker.tags.version>0.1</shiro.freemarker.tags.version>
<qiniu.version>7.5.0</qiniu.version>
<useragentutils.version>1.20</useragentutils.version>
<useragentutils.version>1.21</useragentutils.version>
<braum.version>1.0.0-alpha</braum.version>
<hutool.version>5.5.7</hutool.version>
<spring.web.version>5.1.4.RELEASE</spring.web.version>
<aliyun.oss.version>2.8.3</aliyun.oss.version>
<blog-hunter.version>1.0.4</blog-hunter.version>
<jap.version>1.0.2</jap.version>
<jap.version>1.0.4</jap.version>
</properties>
<dependencyManagement>
......@@ -58,22 +59,22 @@
<dependency>
<groupId>com.zyd</groupId>
<artifactId>blog-core</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</dependency>
<dependency>
<groupId>com.zyd</groupId>
<artifactId>blog-admin</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</dependency>
<dependency>
<groupId>com.zyd</groupId>
<artifactId>blog-web</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</dependency>
<dependency>
<groupId>com.zyd</groupId>
<artifactId>blog-file</artifactId>
<version>2.2.5</version>
<version>${oneblog.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......@@ -101,6 +102,11 @@
<version>${hutool.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Maven控制Spring Profile -->
......@@ -119,17 +125,6 @@
<finalName>${project.artifactId}</finalName>
</build>
</profile>
<!--生产配置-->
<profile>
<id>prod</id>
<properties>
<profileActive>prod</profileActive>
</properties>
<build>
<!-- 产生的构件的文件名-->
<finalName>${project.artifactId}</finalName>
</build>
</profile>
</profiles>
<build>
......