当前位置: 首页 > news >正文

[SpringBoot3]博客管理系统(源码放评论区了)

八、博客管理系统

  • 创建新的SpringBoot项目,综合运用以上知识点,做一个文章管理的后台应用。
  • 依赖:
    • Spring Web
    • Lombok
    • Thymeleaf
    • MyBatis Framework
    • MySQL Driver
    • Bean Validation
    • hutool
  • 需求:文章管理工作,发布新文章,编辑文章,查看文章内容等

8.1配置文件

1.组织配置文件

app-base.yml

article:#最低阅读数low-read: 10#首页显示记录的数量top-read: 20

db.properties(一定要用properties)

#配置数据源
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=030522
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=10
#获取连接时,检测语句
spring.datasource.hikari.connection-test-query=select 1
spring.datasource.hikari.connection-timeout=20000
#其他属性
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.dataSource.cachePrepStmtst=true
spring.datasource.hikari.data-source-properties.dataSource.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.dataSource.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.dataSource.useServerPrepStmts=true

<img src=“C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20230902103338099.png” alt="image-20230902103338099" style="zoom:80%;" />

8.2视图文件

2.logo文件

  • favicon.ico 放在 static/ 根目录下

3.创建模板页面

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

articleList.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title><link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/><script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div style="margin-left: 200px"><h3>阅读最多的20篇文章</h3><table border="1px" cellpadding="0px" cellspacing="0px"><thead><th>选择</th><th>序号</th><th>标题</th><th>副标题</th><th>已读数</th><th>发布时间</th><th>最后修改时间</th><th>操作</th></thead><tbody><tr th:each="article , loopStatus : ${articleList}"><td><input type="checkbox" th:value="${article.id}"></td><td th:text="${loopStatus.index + 1}"></td><td th:text="${article.title}"></td><td th:text="${article.summary}"></td><td th:text="${article.readCount}"></td><td th:text="${article.createTime}"></td><td th:text="${article.updateTime}"></td><td><a th:href="@{/article/get(id=${article.id})}">编辑文章</a> </td></tr><tr><td colspan="8"><table width="100%"><tr><td><button id="add" onclick="addArticle()">发布新文章</button></td><td><button id="del" onclick="deleteArticle()">删除文章</button></td><td><button id="view" onclick="overView()">文章概览</button></td></tr></table></td></tr></tbody></table><form id="frm" th:action="@{/view/addArticle}" method="get"></form><form id="delFrm" th:action="@{/article/remove}" method="post"><input type="hidden" name="ids" id="ids" value=""></form>
</div>
<script>function addArticle(){$("#frm").submit();}function deleteArticle(){var ids=[];$("input[type='checkbox']:checked").each((index,item)=>{ids.push(item.value);})if (ids.length==0){alert("请选择文章");return;}$("#ids").val(ids);$("#delFrm").submit();}function overView(){var ids = [];$("input[type='checkbox']:checked").each( (index,item) =>{ids.push(item.value);})if( ids.length != 1){alert("请选择一个文章查看");return;}$.get("../article/detail/overview",{id: ids[0]}, (data,status)=>{alert(data);})}
</script>
</body>
</html>

addArticle.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title><link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
</head>
<body>
<div style="margin-left: 200px"><h3>发布新的文章</h3><form th:action="@{/article/add}" method="post"><table><tr><td>标题</td><td><input type="text" name="title"></td></tr><tr><td>副标题</td><td><input type="text" name="summary" size="50"></td></tr><tr><td>内容</td><td><textarea name="content" cols="60" rows="20"></textarea></td></tr></table><br/><input type="submit" value="发布新文章" style="margin-left: 200px"></form>
</div>
</body>
</html>

editArticle.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title><link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
</head>
<body>
<div style="margin-left: 200px"><h3>修改文章</h3><form th:action="@{/article/edit}" method="post"><table><tr><td>标题</td><td><input type="text" name="title" th:value="${article.title}"></td></tr><tr><td>副标题</td><td><input type="text" name="summary" size="50" th:value="${article.summary}"></td></tr><tr><td>内容</td><td><textarea name="content" cols="60" rows="20" th:text="${article.content}"></textarea></td></tr></table><br/><input type="hidden" th:value="${article.id}" name="id"><input type="submit" value="确认修改" style="margin-left: 200px"></form>
</div>
</body>
</html>

bind.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title><link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
</head>
<body>
<h3>输入异常</h3>
<table border="1px"><thead><th>字段</th><th>描述</th></thead><tbody><tr th:each="err:${errors}"><td th:text="${err.field}"></td><td th:text="${err.defaultMessage}"></td></tr></tbody>
</table>
</body>
</html>

error.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title><link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
</head>
<body>
<h3>请求错误</h3>
<h3 th:text="${msg}"></h3>
</body>
</html>

8.3Java代码

4.java代码

model包

ArticleDTO

package com.hhb.blog.model.dto;import lombok.Data;@Data
public class ArticleDTO {private Integer id;private String title;private String summary;private String content;
}

ArticleAndDetailMap

package com.hhb.blog.model.map;import lombok.Data;@Data
public class ArticleAndDetailMap {private Integer id;private String title;private String summary;private String content;
}

ArticleParam

package com.hhb.blog.model.param;import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;@Data
public class ArticleParam {//使用JSR303注解public static interface AddArticle{};public static interface EditArticle{};@NotNull(message = "修改时必须有id",groups = {EditArticle.class})@Min(value = 1,message = "文章id大于{value}",groups = {EditArticle.class})private Integer id;@NotBlank(message = "请输入文章标题",groups = {AddArticle.class,EditArticle.class})@Size(min = 2,max = 20,message = "文章标题在{min}-{max}",groups = {AddArticle.class,EditArticle.class})private String title;@NotBlank(message = "请输入文章副标题",groups = {AddArticle.class,EditArticle.class})@Size(min = 10,max=30,message = "文章副标题在{min}-{max}",groups = {AddArticle.class,EditArticle.class})private String summary;@NotBlank(message = "请输入文章内容",groups = {AddArticle.class,EditArticle.class})@Size(min = 20,max = 8000,message = "文章内容至少{min}字,最多{max}字",groups = {AddArticle.class,EditArticle.class})private String content;}

ArticleDeatilPO

package com.hhb.blog.model.po;import lombok.Data;@Data
public class ArticleDetailPO {private Integer id;private Integer articleId;private String content;
}

ArticlePO

package com.hhb.blog.model.po;import lombok.Data;import java.time.LocalDateTime;@Data
public class ArticlePO {private Integer id;private Integer userId;private String title;private String summary;private Integer readCount;private LocalDateTime createTime;private LocalDateTime updateTime;
}

ArticleVO

package com.hhb.blog.model.po;import lombok.Data;import java.time.LocalDateTime;@Data
public class ArticlePO {private Integer id;private Integer userId;private String title;private String summary;private Integer readCount;private LocalDateTime createTime;private LocalDateTime updateTime;
}

mapper包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

ArticleMapper

package com.hhb.blog.mapper;import com.hhb.blog.model.dto.ArticleDTO;
import com.hhb.blog.model.map.ArticleAndDetailMap;
import com.hhb.blog.model.po.ArticleDetailPO;
import com.hhb.blog.model.po.ArticlePO;
import org.apache.ibatis.annotations.*;import java.util.List;public interface ArticleMapper {//查询首页需要的文章列表@Select("""select id,user_id ,title,summary, read_count , create_time, update_timefrom articlewhere read_count >= #{lowRead}order by read_count desc limit #{topRead}""")List<ArticlePO> topSortByReadCount(Integer lowRead, Integer topRead);//添加文章@Insert("""insert into article(user_id, title, summary, read_count, create_time, update_time)values(#{userId},#{title},#{summary},#{readCount},#{createTime},#{updateTime})""")//主键自增@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")int insertArticle(ArticlePO articlePO);//添加文章内容@Insert("""insert into article_detail(article_id, content) values(#{articleId},#{content})""")int insertArticleDetail(ArticleDetailPO articleDetailPO);//两表连接,根据主键查询文章@Select("""select article.id,title,summary,contentfrom article,article_detailwhere article.id=article_detail.article_id and article_id=#{id}""")ArticleAndDetailMap selectArticleAndDetail(Integer id);//修改文章属性@Update("""update article set title=#{title},summary=#{summary},update_time=#{updateTime}where id=#{id}""")int updateArticle(ArticlePO articlePO);//更新文章内容@Update("""update article_detail set content=#{content} where article_id=#{articleId}""")int updateArticleDetail(ArticleDetailPO articleDetailPO);//删除文章@Delete("""<script>delete from article where id in <foreach item="id" collection="idList" open="(" separator="," close=")">#{id}</foreach></script>""")int deleteArticle(List<Integer> idList);//删除文章内容@Delete("""<script>delete from article_detail where article_id in <foreach item="id" collection="idList" open="(" separator="," close=")">#{id}</foreach></script>""")int deleteDetail(List<Integer> idList);//根据id查询内容@Select("""select id,article_id,content from article_detailwhere article_id = #{articleId}""")ArticleDetailPO selectArticleDetailByArticleId(Integer articleId);
}

service包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

ArticleService

package com.hhb.blog.service;import com.hhb.blog.model.dto.ArticleDTO;
import com.hhb.blog.model.po.ArticlePO;import java.util.List;public interface ArticleService {//获取首页文章列表List<ArticlePO> queryTopArticle();//发布文章(article,article_detail)boolean addArticle(ArticleDTO articleDTO);//根据主键查询文章ArticleDTO queryByArticleId(Integer id);//修改文章属性和内容boolean modifyArticle(ArticleDTO articleDTO);//删除文章boolean removeArticle(List<Integer> idList);//查询文章内容前20个字符String queryTop20Content(Integer id);
}

ArticleServiceImpl

package com.hhb.blog.service.impl;import cn.hutool.core.bean.BeanUtil;
import com.hhb.blog.mapper.ArticleMapper;
import com.hhb.blog.model.dto.ArticleDTO;
import com.hhb.blog.model.map.ArticleAndDetailMap;
import com.hhb.blog.model.po.ArticleDetailPO;
import com.hhb.blog.model.po.ArticlePO;
import com.hhb.blog.service.ArticleService;
import com.hhb.blog.settings.ArticleSettings;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;import java.time.LocalDateTime;
import java.util.List;
import java.util.Random;@Service
@RequiredArgsConstructor
public class ArticleServiceImpl implements ArticleService {private final ArticleMapper articleMapper;private final ArticleSettings articleSettings;//构造注入/* public ArticleServiceImpl(ArticleMapper articleMapper) {this.articleMapper = articleMapper;}*/@Overridepublic List<ArticlePO> queryTopArticle() {Integer lowRead = articleSettings.getLowRead();Integer topRead = articleSettings.getTopRead();return articleMapper.topSortByReadCount(lowRead, topRead);}//发布文章@Transactional(rollbackFor = Exception.class)@Overridepublic boolean addArticle(ArticleDTO articleDTO) {//文章ArticlePO articlePO = new ArticlePO();articlePO.setTitle(articleDTO.getTitle());articlePO.setSummary(articleDTO.getSummary());articlePO.setCreateTime(LocalDateTime.now());articlePO.setUpdateTime(LocalDateTime.now());articlePO.setReadCount(new Random().nextInt(1000));articlePO.setUserId(new Random().nextInt(5000));int addArticle = articleMapper.insertArticle(articlePO);//文章内容ArticleDetailPO articleDetailPO = new ArticleDetailPO();articleDetailPO.setArticleId(articlePO.getId());articleDetailPO.setContent(articleDTO.getContent());int addDetail = articleMapper.insertArticleDetail(articleDetailPO);return (addDetail + addArticle) == 2 ? true : false;}@Overridepublic ArticleDTO queryByArticleId(Integer id) {//文章属性,内容ArticleAndDetailMap mapper = articleMapper.selectArticleAndDetail(id);//转为DTO,两种方式/*ArticleDTO articleDTO = new ArticleDTO();articleDTO.setTitle(mapper.getTitle());articleDTO.setContent(mapper.getContent());articleDTO.setSummary(mapper.getSummary());articleDTO.setId(mapper.getId());*/ArticleDTO articleDTO = BeanUtil.copyProperties(mapper, ArticleDTO.class);return articleDTO;}@Transactional(rollbackFor = Exception.class)@Overridepublic boolean modifyArticle(ArticleDTO articleDTO) {//修改文章属性ArticlePO articlePO = new ArticlePO();articlePO.setTitle(articleDTO.getTitle());articlePO.setSummary(articleDTO.getSummary());articlePO.setUpdateTime(LocalDateTime.now());articlePO.setId(articleDTO.getId());int article = articleMapper.updateArticle(articlePO);//修改文章内容ArticleDetailPO articleDetailPO = new ArticleDetailPO();articleDetailPO.setArticleId(articleDTO.getId());articleDetailPO.setContent(articleDTO.getContent());int detail = articleMapper.updateArticleDetail(articleDetailPO);return (article + detail) == 2 ? true : false;}//删除文章属性、内容@Transactional(rollbackFor = Exception.class)@Overridepublic boolean removeArticle(List<Integer> idList) {int article = articleMapper.deleteArticle(idList);int detail = articleMapper.deleteDetail(idList);return article == detail ? true : false;}//查询文章内容前20个字符@Overridepublic String queryTop20Content(Integer id) {ArticleDetailPO articleDetailPO = articleMapper.selectArticleDetailByArticleId(id);String content = "无内容";if( articleDetailPO != null ){content = articleDetailPO.getContent();if(StringUtils.hasText(content)){//content = content.substring(0, content.length() >= 20 ? 20 : content.length() );content = content.substring(0, 20 );}}return content;}
}

controller包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

ArticleController

package com.hhb.blog.controller;import cn.hutool.core.bean.BeanUtil;
import com.hhb.blog.format.IdType;
import com.hhb.blog.handler.exp.IdTypeException;
import com.hhb.blog.model.dto.ArticleDTO;
import com.hhb.blog.model.param.ArticleParam;
import com.hhb.blog.model.po.ArticlePO;
import com.hhb.blog.model.vo.ArticleVO;
import com.hhb.blog.service.ArticleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.util.List;@RequiredArgsConstructor
@Controller
public class ArticleController {private final ArticleService articleService;@GetMapping(value = {"/", "/article/hot"})public String showHotArticle(Model model) {List<ArticlePO> articlePOList = articleService.queryTopArticle();//转为VO  .hutool工具类List<ArticleVO> articleVOList = BeanUtil.copyToList(articlePOList, ArticleVO.class);//添加数据model.addAttribute("articleList", articleVOList);//视图return "/blog/articleList";}//发布新文章@PostMapping("/article/add")//接收对象类型参数public String addArticle(@Validated(ArticleParam.AddArticle.class) ArticleParam param) {ArticleDTO articleDTO = new ArticleDTO();articleDTO.setContent(param.getContent());articleDTO.setSummary(param.getSummary());articleDTO.setTitle(param.getTitle());boolean add = articleService.addArticle(articleDTO);return "redirect:/article/hot";}//查询文章内容@GetMapping("/article/get")public String queryById(Integer id, Model model) {if (id != null && id > 0) {ArticleDTO articleDTO = articleService.queryByArticleId(id);//DTO-VOArticleVO articleVO = BeanUtil.copyProperties(articleDTO, ArticleVO.class);//添加数据model.addAttribute("article", articleVO);//视图return "/blog/editArticle";} else {return "/blog/error/error";}}//更新文章@PostMapping("/article/edit")public String modifyArticle(@Validated(ArticleParam.EditArticle.class) ArticleParam param) {/*ArticleDTO articleDTO = new ArticleDTO();articleDTO.setId(param.getId());articleDTO.setTitle(param.getTitle());articleDTO.setSummary(param.getSummary());articleDTO.setContent(param.getContent());*/ArticleDTO articleDTO = BeanUtil.copyProperties(param, ArticleDTO.class);boolean edit = articleService.modifyArticle(articleDTO);return "redirect:/article/hot";}//删除文章@PostMapping("/article/remove")//public String removeArticle(Integer ids[])public String removeArticle(@RequestParam("ids") IdType idType) {if (idType == null) {throw new IdTypeException("ID为空");}boolean delete = articleService.removeArticle(idType.getIdList());return "redirect:/article/hot";}//预览文章@GetMapping("/article/detail/overview")@ResponseBodypublic String queryDetail(Integer id) {String top20Content = "无ID";if (id != null) {top20Content = articleService.queryTop20Content(id);}return top20Content;}
}

异常处理包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

GlobalExceptionHandler

package com.hhb.blog.handler;import java.util.List;import com.hhb.blog.handler.exp.IdTypeException;
import org.springframework.ui.Model;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;@ControllerAdvice
public class GlobalExceptionHandler {//处理JSR303@ExceptionHandler({BindException.class})public String handlerBindException(BindException bindException, Model model) {BindingResult bindingResult = bindException.getBindingResult();List<FieldError> fieldErrors = bindingResult.getFieldErrors();model.addAttribute("errors", fieldErrors);return "/blog/error/bind";}@ExceptionHandler({IdTypeException.class})public String handleIdTypeException(IdTypeException idTypeException, Model model) {model.addAttribute("msg", idTypeException.getMessage());return "/blog/error/error";}@ExceptionHandler({Exception.class})public String handleDefaultException(Exception e, Model model) {model.addAttribute("msg", "请稍后重试!");return "/blog/error/error";}
}

BlogRootException

package com.hhb.blog.handler.exp;public class BlogRootException extends RuntimeException{public BlogRootException() {}public BlogRootException(String message) {super(message);}
}

IdTypeException

package com.hhb.blog.handler.exp;public class IdTypeException extends BlogRootException {public IdTypeException() {}public IdTypeException(String message) {super(message);}
}

数据格式化包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

IdType

package com.hhb.blog.format;import lombok.Data;import java.util.List;@Data
public class IdType {private List<Integer> idList;
}

IdTypeFormatter

package com.hhb.blog.format;import org.springframework.format.Formatter;
import org.springframework.util.StringUtils;import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;public class IdTypeFormatter implements Formatter<IdType> {@Overridepublic IdType parse(String text, Locale locale) throws ParseException {IdType idType = null;if (StringUtils.hasText(text)) {List<Integer> ids = new ArrayList<>();for (String id : text.split(",")) {ids.add(Integer.parseInt(id));}idType = new IdType();idType.setIdList(ids);}return idType;}@Overridepublic String print(IdType object, Locale locale) {return null;}
}

设置包

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

ArticleSettings

package com.hhb.blog.settings;import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;@Data
@ConfigurationProperties(prefix = "article")
public class ArticleSettings {private Integer lowRead;private Integer topRead;
}

MvcSettings

package com.hhb.blog.settings;import com.hhb.blog.format.IdTypeFormatter;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration
public class MvcSettings implements WebMvcConfigurer {@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/view/addArticle").setViewName("/blog/addArticle");}@Overridepublic void addFormatters(FormatterRegistry registry) {registry.addFormatter(new IdTypeFormatter());}
}

启动类

package com.hhb.blog;import com.hhb.blog.settings.ArticleSettings;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.transaction.annotation.EnableTransactionManagement;@EnableTransactionManagement
@MapperScan(basePackages = "com.hhb.blog.mapper")
@EnableConfigurationProperties({ArticleSettings.class})
@SpringBootApplication
public class Springboot20BlogAdminApplication {public static void main(String[] args) {SpringApplication.run(Springboot20BlogAdminApplication.class, args);}}

8.4界面展示

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

相关文章:

[SpringBoot3]博客管理系统(源码放评论区了)

八、博客管理系统 创建新的SpringBoot项目&#xff0c;综合运用以上知识点&#xff0c;做一个文章管理的后台应用。依赖&#xff1a; Spring WebLombokThymeleafMyBatis FrameworkMySQL DriverBean Validationhutool 需求&#xff1a;文章管理工作&#xff0c;发布新文章&…...

C语言——指针基本语法

概述 内存地址 在计算机内存中&#xff0c;每个存储单元都有一个唯一的地址(内存编号)。 通俗理解&#xff0c;内存就是房间&#xff0c;地址就是门牌号 指针和指针变量 指针&#xff08;Pointer&#xff09;是一种特殊的变量类型&#xff0c;它用于存储内存地址。 指针的实…...

elementui table 在浏览器分辨率变化的时候界面异常

异常点&#xff1a; 界面显示不完整&#xff0c;表格卡顿&#xff0c;界面已经刷新完成&#xff0c;但是表格的宽度还在一点一点变化&#xff0c;甚至有无线延伸的情况 思路&#xff1a; 1. 使用doLayout 这里官方文档有说明&#xff0c; 所以我的想法是&#xff0c;监听浏览…...

六、Kafka-Eagle监控

目录 6.1 MySQL 环境准备6.2 Kafka 环境准备6.3 Kafka-Eagle 安装 6.1 MySQL 环境准备 Kafka-Eagle 的安装依赖于 MySQL&#xff0c;MySQL 主要用来存储可视化展示的数据 6.2 Kafka 环境准备 修改/opt/module/kafka/bin/kafka-server-start.sh 命令 vim bin/kafka-server-sta…...

DBeaver 23.1.5 发布

导读DBeaver 是一个免费开源的通用数据库工具&#xff0c;适用于开发人员和数据库管理员。DBeaver 23.1.5 现已发布&#xff0c;更新内容如下. Data editor 重新设计了词典查看器面板 UI 空间数据类型&#xff1a;曲线几何线性化已修复 数据保存时结果选项卡关闭的问题已解决…...

三种垃圾收集算法,优缺点分析,设计垃圾收集

文章目录 垃圾收集算法标记-清除&#xff08;基础收集算法&#xff09;标记-复制&#xff08;新生代&#xff09;标记-整理&#xff08;老年代&#xff09; 垃圾收集算法 标记-清除&#xff08;基础收集算法&#xff09; 首先标记出所有需要回收的对象&#xff0c;在标记完成后…...

【链表OJ 10】环形链表Ⅱ(求入环节点)

前言: &#x1f4a5;&#x1f388;个人主页:​​​​​​Dream_Chaser&#xff5e; &#x1f388;&#x1f4a5; ✨✨刷题专栏:http://t.csdn.cn/UlvTc ⛳⛳本篇内容:力扣上链表OJ题目 目录 leetcode142. 环形链表 II 1.问题描述 2.代码思路 3.问题分析 leetcode142. 环形链…...

RT-Thread在STM32硬件I2C的踩坑记录

RT-Thread在STM32硬件I2C的踩坑记录 0.前言一、软硬件I2C区别二、RT Thread中的I2C驱动三、尝试适配硬件I2C四、i2c-bit-ops操作函数替换五、Attention Please!六、总结 参考文章&#xff1a; 1.将硬件I2C巧妙地将“嫁接”到RTT原生的模拟I2C驱动框架 2.基于STM32F4平台的硬件I…...

小白学Go基础01-Go 语言的介绍

Go 语言对传统的面向对象开发进行了重新思考&#xff0c;并且提供了更高效的复用代码的手段。Go 语言还让用户能更高效地利用昂贵服务器上的所有核心&#xff0c;而且它编译大型项目的速度也很快。 用 Go 解决现代编程难题 Go 语言开发团队花了很长时间来解决当今软件开发人员…...

Spring工具类--Assert的使用

原文网址&#xff1a;Spring工具类--Assert的使用_IT利刃出鞘的博客-CSDN博客 简介 说明 本文介绍Spring的Assert工具类的用法。 Assert工具类的作用&#xff1a;判断某个字段&#xff0c;比如&#xff1a;断定它不是null&#xff0c;如果是null&#xff0c;则此工具类会报…...

无涯教程-Android - Absolute Layout函数

Absolute Layout 可让您指定其子级的确切位置(x/y坐标)&#xff0c;绝对布局的灵活性较差且难以维护。 Absolute Layout - 属性 以下是AbsoluteLayout特有的重要属性- Sr.NoAttribute & 描述1 android:id 这是唯一标识布局的ID。 2 android:layout_x 这指定视图的x坐标…...

2018ECCV Can 3D Pose be Learned from2D Projections Alone?

摘要 在计算机视觉中&#xff0c;从单个图像的三维姿态估计是一个具有挑战性的任务。我们提出了一种弱监督的方法来估计3D姿态点&#xff0c;仅给出2D姿态地标。我们的方法不需要2D和3D点之间的对应关系来建立明确的3D先验。我们利用一个对抗性的框架&#xff0c;强加在3D结构…...

干旱演变研究:定义及研究方法

在水文系统中,每个组分之间互相关联,包气带水、地下水和河川径流相互响应,水文循环处于动态平衡的状态。 降水作为水文系统的输入量,对水文循环具有重要的影响。降水短缺通过水文循环导致水文系统不同组分(包气带、地下水和地表水)发生干旱,降水不足导致土壤含水量减少,…...

【LeetCode-中等题】114. 二叉树展开为链表

文章目录 题目方法一&#xff1a;前序遍历&#xff08;构造集合&#xff09; 集合&#xff08;构造新树&#xff09;方法二&#xff1a;原地构建方法三&#xff1a;前序遍历--迭代&#xff08;构造集合&#xff09; 集合&#xff08;构造新树&#xff09; 题目 方法一&#x…...

【题解】JZOJ6645 / 洛谷P4090 [USACO17DEC] Greedy Gift Takers P

洛谷 P4090 [USACO17DEC] Greedy Gift Takers P 题意 n n n 头牛排成一列&#xff0c;队头的奶牛 i i i 拿一个礼物并插到从后往前数 c i c_i ci​ 头牛的前面&#xff0c;重复无限次&#xff0c;问多少奶牛没有礼物。 题解 发现若一头牛无法获得礼物&#xff0c;那么它后…...

Vue 项目中的错误如何处理的?

1、 组件中的处理&#xff1a;使用 errorCaptured 钩子 作用&#xff1a;可以捕获来自后代组件的错误 父组件(errorCaptured) -> 子组件 (errorCaptured) -> 当孙子组件出错时&#xff0c;错误会一直向上抛&#xff0c;也就是先触发子组件的 errorCaptured&#xff0c;…...

网络分层的真实含义

复杂的程序都要分层&#xff0c;这是程序设计的要求。比如&#xff0c;复杂的电商还会分数据库层、缓存层、Compose 层、Controller 层和接入层&#xff0c;每一层专注做本层的事情。 当一个网络包从一个网口经过的时候&#xff0c;你看到了&#xff0c;首先先看看要不要请进来…...

RT-Thread 线程间同步

线程间同步 在多线程实时系统中&#xff0c;一项工作的完成往往可以通过多个线程协调的方式共同来完成&#xff0c;那么多个线程之间如何 “默契” 协作才能使这项工作无差错执行&#xff1f;下面举个例子说明。 例如一项工作中的两个线程&#xff1a;一个线程从传感器中接收…...

Python元类再解释

Python元类再解释 元类是什么&#xff1f; 你可以把元类看作是“生产类的工厂”。就像类是用来生产对象的&#xff0c;元类是用来生产类的。 为什么需要元类&#xff1f; 考虑一个场景&#xff1a;假设你正在编写一个框架&#xff0c;你希望框架中的所有类都有某些特定的方…...

常用的Spring Boot 注解及示例代码

简介&#xff1a;Spring Boot 是一个用于快速构建基于 Spring 框架的应用程序的工具&#xff0c;通过提供一系列的注解&#xff0c;它使得开发者可以更加轻松地配置、管理和控制应用程序的各种行为。以下是一些常用的 Spring Boot 注解&#xff0c;以及它们的功能和示例代码&am…...

web vue 项目 Docker化部署

Web 项目 Docker 化部署详细教程 目录 Web 项目 Docker 化部署概述Dockerfile 详解 构建阶段生产阶段 构建和运行 Docker 镜像 1. Web 项目 Docker 化部署概述 Docker 化部署的主要步骤分为以下几个阶段&#xff1a; 构建阶段&#xff08;Build Stage&#xff09;&#xff1a…...

手游刚开服就被攻击怎么办?如何防御DDoS?

开服初期是手游最脆弱的阶段&#xff0c;极易成为DDoS攻击的目标。一旦遭遇攻击&#xff0c;可能导致服务器瘫痪、玩家流失&#xff0c;甚至造成巨大经济损失。本文为开发者提供一套简洁有效的应急与防御方案&#xff0c;帮助快速应对并构建长期防护体系。 一、遭遇攻击的紧急应…...

在HarmonyOS ArkTS ArkUI-X 5.0及以上版本中,手势开发全攻略:

在 HarmonyOS 应用开发中&#xff0c;手势交互是连接用户与设备的核心纽带。ArkTS 框架提供了丰富的手势处理能力&#xff0c;既支持点击、长按、拖拽等基础单一手势的精细控制&#xff0c;也能通过多种绑定策略解决父子组件的手势竞争问题。本文将结合官方开发文档&#xff0c…...

关于iview组件中使用 table , 绑定序号分页后序号从1开始的解决方案

问题描述&#xff1a;iview使用table 中type: "index",分页之后 &#xff0c;索引还是从1开始&#xff0c;试过绑定后台返回数据的id, 这种方法可行&#xff0c;就是后台返回数据的每个页面id都不完全是按照从1开始的升序&#xff0c;因此百度了下&#xff0c;找到了…...

对WWDC 2025 Keynote 内容的预测

借助我们以往对苹果公司发展路径的深入研究经验&#xff0c;以及大语言模型的分析能力&#xff0c;我们系统梳理了多年来苹果 WWDC 主题演讲的规律。在 WWDC 2025 即将揭幕之际&#xff0c;我们让 ChatGPT 对今年的 Keynote 内容进行了一个初步预测&#xff0c;聊作存档。等到明…...

生成 Git SSH 证书

&#x1f511; 1. ​​生成 SSH 密钥对​​ 在终端&#xff08;Windows 使用 Git Bash&#xff0c;Mac/Linux 使用 Terminal&#xff09;执行命令&#xff1a; ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" ​​参数说明​​&#xff1a; -t rsa&#x…...

从零开始打造 OpenSTLinux 6.6 Yocto 系统(基于STM32CubeMX)(九)

设备树移植 和uboot设备树修改的内容同步到kernel将设备树stm32mp157d-stm32mp157daa1-mx.dts复制到内核源码目录下 源码修改及编译 修改arch/arm/boot/dts/st/Makefile&#xff0c;新增设备树编译 stm32mp157f-ev1-m4-examples.dtb \stm32mp157d-stm32mp157daa1-mx.dtb修改…...

Neo4j 集群管理:原理、技术与最佳实践深度解析

Neo4j 的集群技术是其企业级高可用性、可扩展性和容错能力的核心。通过深入分析官方文档,本文将系统阐述其集群管理的核心原理、关键技术、实用技巧和行业最佳实践。 Neo4j 的 Causal Clustering 架构提供了一个强大而灵活的基石,用于构建高可用、可扩展且一致的图数据库服务…...

大语言模型(LLM)中的KV缓存压缩与动态稀疏注意力机制设计

随着大语言模型&#xff08;LLM&#xff09;参数规模的增长&#xff0c;推理阶段的内存占用和计算复杂度成为核心挑战。传统注意力机制的计算复杂度随序列长度呈二次方增长&#xff0c;而KV缓存的内存消耗可能高达数十GB&#xff08;例如Llama2-7B处理100K token时需50GB内存&a…...

网站指纹识别

网站指纹识别 网站的最基本组成&#xff1a;服务器&#xff08;操作系统&#xff09;、中间件&#xff08;web容器&#xff09;、脚本语言、数据厍 为什么要了解这些&#xff1f;举个例子&#xff1a;发现了一个文件读取漏洞&#xff0c;我们需要读/etc/passwd&#xff0c;如…...