动力节点王鹤最新SpringBoot3第八章笔记
8?文章管理模块
创建新的Spring Boot项目,综合运用视频中的知识点,做一个文章管理的后台应用。 新的Spring Boot项目Lession20-BlogAdmin。Maven构建工具,包名称com.bjpowernode.blog JDK19,依赖:
[if !supportLists]·?[endif]Spring Web
[if !supportLists]·?[endif]Lombok
[if !supportLists]·?[endif]Thymeleaf
[if !supportLists]·?[endif]MyBatis Framework
[if !supportLists]·?[endif]MySQL Driver
依赖还需要Bean Validation
需求:文章管理工作,发布新文章,编辑文章,查看文章内容等
8.1?配置文件
step1:组织配置文件[MISSING IMAGE: , ?]
app-base.yml
| article: _#最低文章阅读数量 _low-read: 10 _#首页显示最多的文章数量
_top-read: 20
db.yml
| spring: datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/blog?serverTimezone=Asia/Shanghai username: root password: 123456 hikari: auto-commit: true maximum-pool-size: 10 minimum-idle: 10 _#获取连接时,检测语句 _connection-test-query: select 1 connection-timeout: 20000 _#其他属性 _data-source-properties: cachePrepStmts: true dataSource.cachePrepStmtst: true dataSource.prepStmtCacheSize: 250 dataSource.prepStmtCacheSqlLimit: 2048 dataSource.useServerPrepStmts: true | | --- |
8.2?视图文件
step2: logo文件 favicon.ico放在static/ 根目录下
step3:创建模板页面[MISSING IMAGE: , ?]
articleList.html
|
<form id="delfrm" th:action="@{/article/removeArticle}" method="post">
?<input type="hidden" id="idsDom" name="ids" value="" >
</form>
addArticle.html
8.3?Java代码
step4: java代码
model包:[MISSING IMAGE: , ?]
ArticleVO.java