基于 Spring Boot 的我的博客 FS-Blog

在线 Demo:http://fsblog.letec.topjavascript

Github 地址:https://github.com/jameszbl/fs-blogcss

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. 配置文件

spring:
  # 应用名称
 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
复制代码
相关文章
相关标签/搜索