10-1-Spring Boot综合项目实战-准备工作
一、系统演示与概述
1.演示
项目:简易的博客系统
演示地址:http://32h5354h14.qicp.vip/
2.系统功能介绍
前端使用Spring Boot支持的模板引擎Thymeleaf+jQuery完成页面信息展示
后端使用Spring MVC+Spring Boot+MyBatis框架进行整合开发
3.项目效果预览
前台首页
文章详情页
文章评论页
后台首页
后台文件编辑页面
后台文章管理列表页面
二、项目设计
1.系统开发及运行环境
操作系统:Windows
Java开发包:JDK 8
项目管理工具:Maven 3.6.0
项目开发工具:eclipse 或 IntelliJ IDEA
数据库:MySQL
缓存管理工具:Redis 3.2.100
浏览器:谷歌浏览器
2.文件组织结构
3.数据库设计
文章详情表t_article
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
文章id |
title |
varchar |
50 |
否 |
文章标题 |
content |
longtext |
否 |
文章内容 |
|
created |
date |
否 |
创建时间 |
|
modified |
date |
否 |
修改时间 |
|
categories |
varchar |
200 |
否 |
文章分类 |
tags |
varchar |
200 |
否 |
文章标签 |
allow_comment |
tinyint |
1 |
否 |
是否允许评论(默认1) |
thumbnail |
varchar |
200 |
否 |
文章缩略图 |
文章评论表t_comment
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
评论id |
article_id |
int |
11 |
否 |
评论关联的文章id |
created |
date |
否 |
创建时间 |
|
ip |
varchar |
200 |
否 |
评论用户所在ip |
content |
text |
否 |
评论内容 |
|
status |
varchar |
200 |
否 |
评论状态(默认approved) |
author |
varchar |
200 |
否 |
评论作者名 |
文章统计表t_statistic
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
文章统计id |
article_id |
int |
11 |
否 |
文章id |
hits |
int |
11 |
否 |
文章点击量 |
comments_num |
int |
11 |
否 |
文章评论量 |
用户信息表t_user
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
用户id |
username |
varchar |
200 |
否 |
用户名 |
password |
varchar |
200 |
否 |
用户密码(加密后的密码) |
|
varchar |
200 |
否 |
用户邮箱 |
created |
date |
否 |
创建时间 |
|
valid |
tinyint |
1 |
否 |
是否为有效用户(默认1) |
用户权限表authority
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
权限id |
authority |
varchar |
200 |
否 |
权限以ROLE_开头 |
用户权限关联表t_user_authority
字段名 |
类型 |
长度 |
是否为主键 |
说明 |
id |
int |
11 |
是 |
关联表主键id |
user_id |
int |
11 |
否 |
用户id |
authority_id |
int |
11 |
否 |
权限id |
三、准备数据库资源
创建一个名称为blog_system的数据库,并选择该数据库,关注微信公众号“欧艺软件开发工作室”,发送关键字“java”,
在“SpringBoot企业级开发教程”文件夹下,下载blog_system.sql文件,再导入到blog_system数据库中。
四、准备项目环境
1.创建项目,引入依赖文件
创建一个名称为blog_system的Spring Boot项目,包名:域名反写加项目名
<dependencies>
<!-- 阿里巴巴的Druid数据源依赖启动器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<!-- MyBatis依赖启动器 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!-- MySQL数据库连接驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Redis服务启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- mail邮件服务启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- thymeleaf模板整合security控制页面安全访问依赖 -->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<!-- Spring Security依赖启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Thymeleaf模板引擎启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Web服务启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MyBatis分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!-- String工具类包-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<!-- Markdown处理html -->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.11.0</version>
</dependency>
<!-- Markdown处理表格 -->
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark-ext-gfm-tables</artifactId>
<version>0.11.0</version>
</dependency>
<!-- 过滤emoji表情字符 -->
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
<!-- devtools热部署工具 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Spring Boot测试服务启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
2.编写配置文件
a.将application.properties全局配置文件更名为application.yml
server:
port: 8081
spring:
profiles:
# 外置jdbc、redis和mail配置文件
active: jdbc,redis,mail,test
# 关闭thymeleaf页面缓存
thymeleaf:
cache: false
# 配置国际化资源文件
messages:
basename: i18n.logo
# MyBatis配置
mybatis:
configuration:
#开启驼峰命名匹配映射
map-underscore-to-camel-case: true
#控制台打印日志,能打印出被扫描的包和被解析的映射文件,以后再验证 -- 但下面的logging配置失效
#Scanned package: 'com.itheima.myblog.model.domain' for aliases
#Parsed mapper file: 'file [E:\myproject\blogForTeach\blog-for-teach。。。
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#配置MyBatis的xml映射文件路径
mapper-locations: classpath:mapper/*.xml
#配置XML映射文件中指定的实体类别名路径
type-aliases-package: com.itheima.myblog.model.domain
#mybatis日志显示SQL
logging:
level:
com.itheima.myblog.mapper: debug
#pagehelper分页设置
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
#浏览器cookie相关设置
COOKIE:
# 设置cookie默认时长为30分钟
VALIDITY: 1800
b.创建application-jdbc.properties
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
spring.datasource.initialSize=20
spring.datasource.minIdle=10
spring.datasource.maxActive=100
spring.datasource.url=jdbc:mysql://localhost:3306/blog_system?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false#MySQL在高版本需要指明是否进行SSL连接
spring.datasource.username=root
spring.datasource.password=root
c.创建application-mail.properties
spring.mail.host=smtp.sina.com
spring.mail.port=587
spring.mail.username=lxtestemail@sina.com
spring.mail.password=zx123456
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.writetimeout=5000
d.创建application-redis.properties
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
3.前端资源引入
4.后端基础代码引入
报错:References to interface static methods are allowed only at source level 1.8
Pom文件的properties标签中添加
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
10-1-Spring Boot综合项目实战-准备工作相关推荐
- 【Spring Boot论坛项目实战】3、开发社区核心功能
文章列表: 1.初识Spring Boot,开发社区首页 2.开发社区登录模块 3.开发社区核心功能 开发社区核心功能 1 过滤敏感词 前缀树:根节点为空,除了根节点外的节点只包含一个字母 检测敏感词 ...
- springboot做网站_Github点赞接近 100k 的Spring Boot学习教程+实战项目推荐!
" 本文已经收录进:awesome-java (Github 上非常棒的 Java 开源项目集合) 很明显的一个现象,除了一些老项目,现在 Java 后端项目基本都是基于 Spring Bo ...
- 10个Spring Boot 优秀学习项目
10个Spring Boot 优秀学习项目 10个SpringBoot项目分享(好像多了一个项目) 一.mall (虽然培训机构已经把电商推广了烂大街了,但技术还是可以学习的) 二.Cloud-Pla ...
- Spring Boot 高效入门实战
凭借开箱即用,远离繁琐的配置等特性,Spring Boot 已经成为 Java 开发者人人必学必会的开源项目.那么开发者该如何快速上手Spring Boot 呢? 进入Spring Boot世界 Ja ...
- Spring Boot 揭秘与实战(二) 数据缓存篇 - Guava Cache
本文,讲解 Spring Boot 如何集成 Guava Cache,实现缓存. 博客地址:blog.720ui.com/ 在阅读「Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门」 ...
- 15 个优秀开源的 Spring Boot 学习项目,一网打尽!
Spring Boot 算是目前 Java 领域最火的技术栈了,松哥年初出版的 <Spring Boot + Vue 全栈开发实战>迄今为止已经加印了 8 次,Spring Boot 的受 ...
- 10本 Spring Boot 学习书籍-个人记载
如果大家在犯愁找不到对应的spring书籍,可以参考下面的几本书籍,博主只买了两本参考: Spring Boot是Spring社区发布的一个开源项目,旨在帮助开发者快速并且更简单的构建项目.Sprin ...
- 猿创征文 | 微服务 Spring Boot 整合Redis 实战开发解决高并发数据缓存
文章目录 一.什么是 缓存? ⛅为什么用缓存? ⚡如何使用缓存 二.实现一个商家缓存 ⌛环境搭建 ♨️核心源码 ✅测试接口 三.采用 微服务 Spring Boot 注解开启缓存 ✂️@CacheEn ...
- Java Spring Boot 2.0实战Docker容器与架构原理,视频与课件,基于Linux环境...
Java Spring Boot 2.0实战Docker容器Linux与架构原理 内容摘要:Docker是最流行的开源容器引擎,Go语言开发,在互联网大规模集群.云计算.微服务等架构中广泛使用.本次课 ...
最新文章
- Rails字符集问题
- Linux 永久挂载(mount)
- 又是加拿大!连年拒签NeurIPS参会者被指太荒唐,Hinton亲自过问也没辙
- Linux基础-yum软件包管理
- mysql第五章项目二_Todo List:Node+Express 搭建服务端毗邻Mysql – 第五章(第1节)
- Linux使用imagemagick的convert命令压缩图片、节省服务器空间
- 使用Python requests post上传图片及示例demo
- 利用jQuery点击DIV变颜色的小例子
- 设计模式之——静态代理模式
- OpenGL ES之GLSurfaceView学习一:介绍
- 亿图图示上线小程序,MindMaster移动端迎来大更新,亿图软件八周年再出发
- k近邻算法_K近邻算法(一)
- 288芯光缆交接箱光交箱图文详解
- linux yum下载不安装,CentOS 7设置yum仅仅下载rpm不安装总结
- 基于python的RGB图像转灰度图
- el-table的纵向合并 横向合并 表头合并
- 2021中科院计算机博士,北京:中国科学院大学2021年秋季入学博士招生考试初试进入复试基本分数线要求的通知...
- 试推导取自总体X(期望为μ,方差为σ^2)的样本X1,X2...Xn的样本方差S^2的期望
- 京东金融客户端用户触达方式的探索与实践
- mysql使用jdbc连接增加ssl认证
热门文章
- u-boot移植随笔:使用svn进行版本控制
- 复数幂用java程序怎么求_蓝桥杯——复数幂 (2018JavaAB组第3题)
- 【Elasticsearch】es mapper_parsing_exception
- 【java】java boolean 源码分析
- 【Kafka】kafka 创建 topic的时候 Replication factor 参数理解
- es max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
- 【Linux】Linux查看机器负载-IO负载
- 【aviator】aviator 报错 Syntax error:Unexpect token 'OR' Parsing expression
- Bash shell脚本打印出正在执行的命令
- java集合,Collection,list,set,map汇总