[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界面展示

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

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/124898.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Databend 数据集成方案 | Data Infra 第 15 期

本期的 Data Infra 直播活动我们邀请到了 Databend Cloud 研发工程师-韩山杰&#xff0c;与大家分享主题为《 Databend 数据集成方案》的相关知识。 在本次分享中&#xff0c;你将会学到在云上基于 Databend 及 Databend Cloud 构建应用&#xff0c;掌握 Databend CDC 和 Data…

基于改进莱维飞行和混沌映射的粒子群优化算法(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

[国产MCU]-W801开发实例-MQTT客户端通信

MQTT客户端通信 文章目录 MQTT客户端通信1、MQTT介绍2、W801的MQTT客户端相关API介绍3、代码实现本文将详细介绍如何在W801中使用MQTT协议通信。 1、MQTT介绍 MQTT 被称为消息队列遥测传输协议。它是一种轻量级消息传递协议,可通过简单的通信机制帮助资源受限的网络客户端。 …

Sumo中Traci.trafficlight详解(上)

Sumo中Traci.trafficlight详解&#xff08;上&#xff09; 记录慢慢学习traci的每一天&#xff0c;希望也能帮到你 文章目录 Sumo中Traci.trafficlight详解&#xff08;上&#xff09;Traci.trafficlight信号灯参数讲解1.getAllProgramLogics(self,tlsID)2.getBlockingVehicle…

排序算法的稳定性

稳定性&#xff1a;对于一个数&#xff0c;经过多次排序&#xff0c;保留一个数之间的相对次序 在基础类型数据上&#xff0c;稳定性用处不大 在非基础类型上&#xff0c;可以做到对于相同元素来说&#xff0c;排完序相同元素之间的相对次序不变 归并排序在merge的过程中先拷贝…

Vulnhub: Masashi: 1靶机

kali&#xff1a;192.168.111.111 靶机&#xff1a;192.168.111.236 信息收集 端口扫描 nmap -A -sC -v -sV -T5 -p- --scripthttp-enum 192.168.111.236查看80端口的robots.txt提示三个文件 snmpwalk.txt内容&#xff0c;tftp服务在1337端口 sshfolder.txt内容&#xff0c…

【电路参考】缓启动电路

一、外部供电直接上电可能导致的问题 1、在热拔插的过程中&#xff0c;两个连接器的机械接触&#xff0c;触点在瞬间会出现弹跳&#xff0c;电源不稳&#xff0c;发生震荡。这期间系统工作可能造成不稳定。 2、由于电路中存在滤波或大电解电容&#xff0c;在上电瞬间&#xff…

windows苹果商店上架ipa(基于appuploader)

参考文章&#xff1a; 上传ipa到appstore详细步骤 1、苹果商店地址&#xff1a;https://appstoreconnect.apple.com/apps 2、创建我的app 使用hbuilderx或apicloud云打包后&#xff0c;会生成一个ipa文件&#xff0c;而iphone是无法直接安装这个ipa文件的&#xff0c;需要将这…

大数据课程L2——网站流量项目的算法分析数据处理

文章作者邮箱:yugongshiye@sina.cn 地址:广东惠州 ▲ 本章节目的 ⚪ 了解网站流量项目的算法分析; ⚪ 了解网站流量项目的数据处理; 一、项目的算法分析 1. 概述 网站流量统计是改进网站服务的重要手段之一,通过获取用户在网站的行为,可以分析出哪些内…

uni-app之android原生插件开发

一 插件简介 1.1 当HBuilderX中提供的能力无法满足App功能需求&#xff0c;需要通过使用Andorid/iOS原生开发实现时&#xff0c;可使用App离线SDK开发原生插件来扩展原生能力。 1.2 插件类型有两种&#xff0c;Module模式和Component模式 Module模式&#xff1a;能力扩展&…

WordPress(4)关于网站的背景图片更换

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言一、更改的位置1. 红色区域是要更换的随机的图片二、替换图片位置三.开启随机数量四.结束前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也…

[B题]2023 年全国大学生数学建模比赛思路、代码更新中.....

目录 &#x1f4a5;1 概述 &#x1f4da;2 题目下载 &#x1f389;3 参考文献 &#x1f308;4 思路、代码更新..... &#x1f4a5;1 概述 单波束测深是利用声波在水中的传播特性来测量水体深度的技术。声波在均匀介质中作匀 速直线传播&#xff0c;在不同界面上产生反射&…

脚本:python实现樱花树

文章目录 代码效果 代码 from turtle import * from random import * from math import * def tree(n, l):pd () # 下笔# 阴影效果t cos ( radians ( heading () 45 ) ) / 8 0.25pencolor ( t, t, t )pensize ( n / 3 )forward ( l ) # 画树枝if n > 0:b random () *…

使用CUDA计算GPU的理论显存带宽

文章目录 一、显存带宽和理论显存带宽1. 显存带宽2. 理论显存带宽1&#xff09;计算公式2&#xff09;举例 二、利用CUDA计算理论显存带宽 一、显存带宽和理论显存带宽 1. 显存带宽 显存带宽是指显存和GPU计算单元之间的数据传输速率。 显存带宽越大&#xff0c;意味着数据传…

DAY07_Maven高级——分模块开发与设计依赖管理聚合与继承属性管理多环境配置与应用私服

目录 一 分模块开发与设计1. 分模块开发的意义问题导入模块拆分原则 2. 分模块开发问题导入2.1 创建Maven模块2.2 书写模块代码2.3 通过maven指令安装模块到本地仓库&#xff08;install指令&#xff09; 二 依赖管理1. 依赖传递问题导入 2. 可选依赖问题导入 3. 排除依赖问题导…

vue3哪个数组方法在vue2上做了升级处理

在 Vue 3 中&#xff0c;v-for 指令的数组更新行为进行了升级处理。在 Vue 2 中&#xff0c;当使用 v-for 渲染数组时&#xff0c;如果对数组进行了以下操作&#xff0c;Vue 无法检测到变化&#xff1a; 直接通过索引修改数组元素&#xff0c;例如 arr[0] newValue修改数组的…

C++学习笔记--函数重载(2)

文章目录 1.3、Function Templates Handling1.3.1、Template Argument Deduction1.3.2、Template Argument Substitution 1.4、Overload Resolution1.4.1、Candidate functions1.4.2、Viable functions1.4.3、Tiebreakers 1.5、走一遍完整的流程1.6、Name Mangling1.7、总结 1.…

使用Jsmooth打包JavaFx程序为EXE文件

配置IDEA 第一步&#xff1a; 第二步&#xff1a; MANIFEST.MF的文件路径&#xff0c;必须在resources文件夹中&#xff0c;如果没有&#xff0c;就创建一个。 第三步&#xff1a;配置项目所需jar包的相对路径 最后&#xff1a; 点击确定后&#xff0c;编译Jar 配置Jsmooth …

Druid LogFilter输出可执行的SQL

配置 测试代码&#xff1a; DruidDataSource dataSource new DruidDataSource(); dataSource.setUrl("xxx"); dataSource.setUsername("xxx"); dataSource.setPassword("xxx"); dataSource.setFilters("slf4j"); dataSource.setVal…

保姆级 C++ 学习路线

上周有小伙伴留言求安排一手C/C学习路线&#xff0c;这周一份保姆级的C语言安排上&#xff01; 以前就写过C语言的学习路线&#xff1a;可能是北半球最好的零基础C语言学习路线&#xff0c;这次把C的学习路线也安排上&#xff0c;专门花了一个多月写了这篇学习路线&#xff0c;…