基於 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
複製代碼
相關文章
相關標籤/搜索