在线 Demo:http://fsblog.letec.top
Github 地址:https://github.com/jameszbl/fs-blog
1. 涉及技术及工具
- 核心框架:SpringBoot
- ORM 框架:MyBatis
- MyBatis 工具:MyBatis Mapper
- MVC 框架:Spring MVC
- 模板引擎:Freemarker
- 编译辅助插件:Lombok
- CSS 框架:BootStrap 4.0
- Markdown 编辑器:Editor.md
- 数据库:MySQL
2. 效果图
2.1 首页
2.2 博客列表页
2.3 博客阅读页
2.4 个人简历页
2.5 文章编辑
3. 构建及运行
3.1 服务器环境
- 安装
MySQL
- 安装
Gradle
- 在项目目录下运行
gradle clean build
,生成的 jar 包位于build/libs
目录下,使用java -jar .../fsblog.jar
运行 - 在
application-dev.yml
中配置数据库用户名和密码,默认为:username: root password: root
- 默认自动创建数据库、数据表并自动导入初始数据,同样在
application-dev.yml
中配置3.2 开发环境
- 可直接在 IntelliJ IDEA 或 Eclipse 中打开项目进行二次开发
4. 配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114spring:
# 应用名称
application:
name: FS-Blog
# 缓存
cache:
cache-names: ehcache
ehcache:
# 缓存的配置文件
config: ehcache.xml
# Spring Boot 热部署工具
devtools:
restart:
enabled: true
# 模板引擎
freemarker:
enabled: true
cache: false
suffix: .ftl
charset: utf-8
# 逻辑视图名(所有视图都要写在这里)
view-names: index,
error,
userlogin,
adminlogin,
register,
article,
posts,
admin/index,
admin/userlogin,
admin/blogadd,
admin/blog_manage,
admin/blog_modify,
admin/admin_user_manage,
admin/admin_user_pwd_modify
content-type: text/html
allow-request-override: true
check-template-location: true
expose-request-attributes: true
expose-session-attributes: true
expose-spring-macro-helpers: true
request-context-attribute: request
template-loader-path: classpath:/templates/
# 静态资源
resources:
chain:
strategy:
content:
enabled: true
# 静态资源位置
paths: /**
fixed:
enabled: true
paths: /js/lib
version: v12
static-locations: classpath:/static/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/public/
# 数据源
datasource:
type: com.zaxxer.hikari.HikariDataSource
# 数据库连接
# 用户名
username: root
# 密码
password: root
# 数据库 URL
url: jdbc:mysql://127.0.0.1:3306?useUnicode:true&characterEncoding:UTF-8
# 数据库连接驱动
driverClassName: com.mysql.jdbc.Driver
# SQL 编码
sql-script-encoding: UTF-8
hikari:
# 连接存活时间
connection-timeout: 30000
# 连接池容量
maximum-pool-size: 50
minimum-idle: 5
# 数据库定义
schema: classpath:schema.sql
# 测试数据
data: classpath:data.sql
# 是否自动创建数据库并自动导入初始数据
initialize: true
continue-on-error: true
# 服务器配置
server:
# 端口
port: 8083
max-http-header-size: 8192
compression:
min-response-size: 512
enabled: true
mime-types: text/html,text/css,text/javascript,application/javascript,image/gif,image/png,image/jpg
tomcat:
maxThreads: 12
minSpareThreads: 3
# 访问日志
accesslog:
directory: /home/fullstack/app/fullstack
pattern: combined
enabled: true
# 会话
session:
cookie:
# Session 存活时间
max-age: 1800
# 日志
logging:
# Log4j2 配置文件
config: classpath:log4j2.xml
mybatis:
# 实体类所在包
type-aliases-package: me.zbl.fullstack.entity
# xml 文件位置
mapper-locations: classpath:mapping/*.xml