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

JDK20 + SpringBoot 3.1.0 + JdbcTemplate 使用

JDK20 + SpringBoot 3.1.0 + JdbcTemplate 使用

  • 一.测试数据库 Postgres
  • 二.SpringBoot项目
    • 1.Pom 依赖
    • 2.配置文件
    • 3.启动类
    • 4.数据源配置类
    • 5.实体对象类包装类
    • 6.测试用实体对象
      • 1.基类
      • 2.扩展类
    • 7.测试类

通过 JdbcTemplate 直接执行 SQL 语句,结合源码动态编译即可方便实现动态修改代码逻辑的效果

一.测试数据库 Postgres

在这里插入图片描述

-- public.tb_rabbit_basic definition-- Drop table-- DROP TABLE public.tb_rabbit_basic;CREATE TABLE public.tb_rabbit_basic (id int4 NULL,animal_name varchar NULL,country varchar NULL
);

二.SpringBoot项目

1.Pom 依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>JdbcTemplateDemo</artifactId><version>1.0-SNAPSHOT</version><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>18</source><target>18</target></configuration></plugin></plugins></build><properties><maven.compiler.source>20</maven.compiler.source><maven.compiler.target>20</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><spring-boot.version>3.1.0</spring-boot.version></properties><!--配置阿里云依赖包和插件仓库--><repositories><repository><id>aliyun</id><url>https://maven.aliyun.com/repository/central/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>${spring-boot.version}</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.26</version></dependency><!--druid--><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.16</version><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-autoconfigure</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId></exclusion></exclusions></dependency><!--        mybatis--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>3.0.2</version><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-autoconfigure</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId></exclusion></exclusions></dependency><!-- pgsql --><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.6.0</version></dependency></dependencies>
</project>

2.配置文件

server:port: 8081spring:datasource:postgres:readTimeout: 259200000 # 3 * 24 * 60 * 60 * 1000druid:username: postgrespassword: 123456url: jdbc:postgresql://127.0.0.1:5432/wiki_animal_dbdriverClassName: org.postgresql.Drivertype: com.alibaba.druid.pool.DruidDataSource# 下面为连接池的补充设置,应用到上面所有数据源中# 初始化大小,最小,最大initial-size: 5min-idle: 5max-active: 20# 配置获取连接等待超时的时间max-wait: 60000# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒time-between-eviction-runs-millis: 60000# 配置一个连接在池中最小生存的时间,单位是毫秒min-evictable-idle-time-millis: 300000validation-query: select version()test-while-idle: truetest-on-borrow: falsetest-on-return: false# 打开PSCache,并且指定每个连接上PSCache的大小pool-prepared-statements: true#   配置监控统计拦截的filters,去掉后监控界面sql无法统计,wall用于防火墙max-pool-prepared-statement-per-connection-size: 20filters: stat,walluse-global-data-source-stat: true# 通过connectProperties属性来打开mergeSql功能;慢SQL记录connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

3.启动类

package org.example;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** @author moon*/
@SpringBootApplication
public class JdbcApp {public static void main(String[] args) {SpringApplication.run(JdbcApp.class, args);}
}

4.数据源配置类

package org.example.config;import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;import java.sql.SQLException;
import java.util.Properties;/*** @author moon* @date 2023-09-12 12:00* @since 1.8*/
@Slf4j
@Configuration
public class PostgresDataSource {/*** Postgres readTimeout 超时 暂定 3D 可能导致存在大量 socket 死链接*/@Value("${spring.datasource.postgres.readTimeout}")private int readTimeout;@Bean(name = "druidProperties")@ConfigurationProperties(prefix = "spring.datasource")public Properties druidProperties(){return new Properties();}/*** @description: 数据源* @params: [properties]* @return: com.alibaba.druid.pool.DruidDataSource* @create: 2023-09-12*/@Primary@Bean(name = "druidDataSource")public DruidDataSource druidDataSource(@Qualifier("druidProperties") Properties properties){DruidDataSource druidDataSource = new DruidDataSource();druidDataSource.configFromPropety(properties);try {druidDataSource.setSocketTimeout(readTimeout);druidDataSource.init();} catch (SQLException e) {log.error("Postgres Datasource Init Exception:",e);}return druidDataSource;}/*** jdbc template* @param druidDataSource* @return*/@Bean(name = "postgresTemplate")public JdbcTemplate postgresTemplate(@Qualifier("druidDataSource") DruidDataSource druidDataSource){return new JdbcTemplate(druidDataSource);}
}

5.实体对象类包装类

用于配置实体对象类,方便解析 JdbcTemplate 查询的返回值
package org.example.config;import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.NotWritablePropertyException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;import java.beans.PropertyDescriptor;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;/*** @author moon* @date 2023-09-11 18:08* @since 1.8*/
@Slf4j
@Component
public class ColumnRowMap {private Map<String,MultiColumnRowMapper> map = new HashMap<>(16);Semaphore semaphore = new Semaphore(1);/*** 获取类包装对象* @param clazz* @return*/public MultiColumnRowMapper getColumnRowMap(Class<?> clazz) {while (true){boolean acquire = false;try {acquire = semaphore.tryAcquire(3, TimeUnit.SECONDS);if (acquire){MultiColumnRowMapper mapper = map.get(clazz.getName());if (null == mapper){mapper = new MultiColumnRowMapper<>(clazz);map.put(clazz.getName(),mapper);}//返回return mapper;}} catch (InterruptedException e) {log.error("get column row map exception:",e);} finally {if (acquire){semaphore.release();}}}}static class MultiColumnRowMapper<T> implements RowMapper<T> {/*** 日志*/protected final Log logger = LogFactory.getLog(this.getClass());/*** 转换类型*/@Nullableprivate Class<T> requiredType;/*** 缓存类属性*/@Nullableprivate Map<String, PropertyDescriptor> mappedFields;@Nullableprivate Set<String> mappedProperties;private boolean primitivesDefaultedForNullValue = true;/*** 是否校验属性一致*/private boolean checkFullyPopulated = false;public void setCheckFullyPopulated(boolean checkFullyPopulated) {this.checkFullyPopulated = checkFullyPopulated;}public boolean isCheckFullyPopulated() {return this.checkFullyPopulated;}public void setPrimitivesDefaultedForNullValue(boolean primitivesDefaultedForNullValue) {this.primitivesDefaultedForNullValue = primitivesDefaultedForNullValue;}public boolean isPrimitivesDefaultedForNullValue() {return this.primitivesDefaultedForNullValue;}/*** 构造并解析目标类属性信息* @param requiredType*/public MultiColumnRowMapper(Class<T> requiredType) {this.requiredType = requiredType;init();}/*** 解析属性*/private void init(){PropertyDescriptor[] var2 = BeanUtils.getPropertyDescriptors(requiredType);int var3 = var2.length;this.mappedFields = new HashMap(var3);this.mappedProperties = new HashSet(var3);for(int var4 = 0; var4 < var3; ++var4) {PropertyDescriptor pd = var2[var4];if (pd.getWriteMethod() != null) {String lowerCaseName = this.lowerCaseName(pd.getName());this.mappedFields.put(lowerCaseName, pd);String underscoreName = this.underscoreName(pd.getName());if (!lowerCaseName.equals(underscoreName)) {this.mappedFields.put(underscoreName, pd);}this.mappedProperties.add(pd.getName());}}}/*** 将返回信息转为指定类对象* @param rs* @param rowNumber* @return* @throws SQLException*/@Nullablepublic T mapRow(ResultSet rs, int rowNumber) throws SQLException {ResultSetMetaData rsmd = rs.getMetaData();int columnCount = rsmd.getColumnCount();T mappedObject = BeanUtils.instantiateClass(requiredType);Set<String> populatedProperties = this.isCheckFullyPopulated() ? new HashSet() : null;BeanWrapperImpl bw = new BeanWrapperImpl();bw.setBeanInstance(mappedObject);PropertyDescriptor pd;for(int index = 1; index <= columnCount; ++index) {String column = JdbcUtils.lookupColumnName(rsmd, index);String field = this.lowerCaseName(StringUtils.delete(column, " "));pd = this.mappedFields != null ? this.mappedFields.get(field) : null;if (pd != null) {try {Object value = this.getColumnValue(rs, index, pd);if (rowNumber == 0 && this.logger.isDebugEnabled()) {this.logger.debug("Mapping column '" + column + "' to property '" + pd.getName() + "' of type '" + ClassUtils.getQualifiedName(pd.getPropertyType()) + "'");}try {bw.setPropertyValue(pd.getName(), value);} catch (TypeMismatchException var14) {if (value != null || !this.primitivesDefaultedForNullValue) {throw var14;}if (this.logger.isDebugEnabled()) {this.logger.debug("Intercepted TypeMismatchException for row " + rowNumber + " and column '" + column + "' with null value when setting property '" + pd.getName() + "' of type '" + ClassUtils.getQualifiedName(pd.getPropertyType()) + "' on object: " + mappedObject, var14);}}if (populatedProperties != null) {populatedProperties.add(pd.getName());}} catch (NotWritablePropertyException var15) {throw new DataRetrievalFailureException("Unable to map column '" + column + "' to property '" + pd.getName() + "'", var15);}}}//校验属性一致性if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) {throw new InvalidDataAccessApiUsageException("Given ResultSet does not contain all fields necessary to populate object of " + this.requiredType.getName() + ": " + this.mappedProperties);} else {return mappedObject;}}@Nullableprotected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());}protected String lowerCaseName(String name) {return name.toLowerCase(Locale.US);}protected String underscoreName(String name) {if (!StringUtils.hasLength(name)) {return "";} else {StringBuilder result = new StringBuilder();result.append(Character.toLowerCase(name.charAt(0)));for(int i = 1; i < name.length(); ++i) {char c = name.charAt(i);if (Character.isUpperCase(c)) {result.append('_').append(Character.toLowerCase(c));} else {result.append(c);}}return result.toString();}}}}

6.测试用实体对象

1.基类

package org.example.entity;import lombok.Data;/*** @author moon* @date 2023-09-12 10:45* @since 1.8*/
@Data
public class BaseAnimal {private int id;private String animalName;private String country;}

2.扩展类

package org.example.entity;/*** @author moon* @date 2023-09-12 10:48* @since 1.8*/
public class Rabbit extends BaseAnimal{
}

7.测试类

package org.example.controller;import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.config.ColumnRowMap;
import org.example.entity.Rabbit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;
import java.util.Map;/*** @author moon* @date 2023-09-12 11:52* @since 1.8*/
@Slf4j
@RestController
@RequestMapping("/animal")
public class AnimalController {@Resource(name = "postgresTemplate")private JdbcTemplate postgresTemplate;@Autowiredprivate ColumnRowMap columnRowMap;/*** 插入 通过 ? 参数占位符*/@GetMapping("/insert")public void insert(){postgresTemplate.update("INSERT INTO PUBLIC.TB_RABBIT_BASIC (ID, ANIMAL_NAME, COUNTRY) VALUES (?,?,?)",18,"海棠兔","法国");}/*** 批量插入*/@GetMapping("/batchInsert")public void batchInsert(){List<Object[]> list = new ArrayList<>(3);list.add(new Object[]{19,"海棠兔","法国"});list.add(new Object[]{20,"喜马拉雅兔","中国"});list.add(new Object[]{30,"野兔","比利时"});postgresTemplate.batchUpdate("INSERT INTO PUBLIC.TB_RABBIT_BASIC (ID, ANIMAL_NAME, COUNTRY) VALUES (?,?,?)",list);}/*** 更新*/@GetMapping("/update")public void update(){postgresTemplate.update("UPDATE PUBLIC.TB_RABBIT_BASIC SET COUNTRY = ? WHERE ID = ?","法国+",19);}/*** 更新*/@GetMapping("/batchUpdate")public void batchUpdate(){List<Object[]> list = new ArrayList<>(3);list.add(new Object[]{"法国+++",19});list.add(new Object[]{"中国+++",20});list.add(new Object[]{"比利时+++",30});postgresTemplate.batchUpdate("UPDATE PUBLIC.TB_RABBIT_BASIC SET COUNTRY = ? WHERE ID = ?",list);}/*** 删除*/@GetMapping("/delete")public void delete(){postgresTemplate.update("DELETE FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?",19);}/*** 批量删除*/@GetMapping("/batchDelete")public int[] batchDelete(){List<Object[]> list = new ArrayList<>();list.add(new Object[]{19});list.add(new Object[]{20});list.add(new Object[]{30});int[] result = postgresTemplate.batchUpdate("DELETE FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?",list);return  result;}/*** 查询 select ** @return*/@GetMapping("/queryForMap")public Map<String, Object> queryForMap(){return postgresTemplate.queryForMap("SELECT * FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?",18);}/*** 查询 query for row set* @return*/@GetMapping("/queryForRowSet")public void queryForRowSet(){SqlRowSet rowSet = postgresTemplate.queryForRowSet("SELECT * FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?",18);while (rowSet.next()){int rowId = rowSet.getRow();Integer ID = rowSet.getInt("ID");String ANIMAL_NAME = rowSet.getString("ANIMAL_NAME");String COUNTRY = rowSet.getString("COUNTRY");log.info("rowId {} id {} animalName {} country {}",rowId,ID,ANIMAL_NAME,COUNTRY);}}/*** 查询 query for object* @return*/@GetMapping("/queryForObject")public Object queryForObject(){return postgresTemplate.queryForObject("SELECT ID AS id FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?", Integer.class,18);}/*** 查询 query for object* @return*/@GetMapping("/queryForObjectMapper")public Object queryForObjectMapper(){return postgresTemplate.queryForObject("SELECT ID AS id, ANIMAL_NAME AS animalName, COUNTRY AS country FROM PUBLIC.TB_RABBIT_BASIC WHERE ID = ?",columnRowMap.getColumnRowMap(Rabbit.class),18);}/*** 查询 query for object* @return*/@GetMapping("/queryForList")public List<Map<String, Object>> queryForList(){return postgresTemplate.queryForList("SELECT ID AS id, ANIMAL_NAME AS animalName, COUNTRY AS country FROM PUBLIC.TB_RABBIT_BASIC");}/*** 查询 query for object class* @return*/@GetMapping("/queryForListClass")public List<Rabbit> queryForListClass(){return postgresTemplate.query("SELECT ID AS id, ANIMAL_NAME AS animalName, COUNTRY AS country FROM PUBLIC.TB_RABBIT_BASIC",columnRowMap.getColumnRowMap(Rabbit.class));}
}

以批量查询为例:http://127.0.0.1:8081/animal/queryForListClass

在这里插入图片描述

相关文章:

JDK20 + SpringBoot 3.1.0 + JdbcTemplate 使用

JDK20 SpringBoot 3.1.0 JdbcTemplate 使用 一.测试数据库 Postgres二.SpringBoot项目1.Pom 依赖2.配置文件3.启动类4.数据源配置类5.实体对象类包装类6.测试用实体对象1.基类2.扩展类 7.测试类 通过 JdbcTemplate 直接执行 SQL 语句&#xff0c;结合源码动态编译即可方便实现…...

CTFhub_SSRF靶场教程

CTFhub SSRF 题目 1. Bypass 1.1 URL Bypass 请求的URL中必须包含http://notfound.ctfhub.com&#xff0c;来尝试利用URL的一些特殊地方绕过这个限制吧 1.利用?绕过限制urlhttps://www.baidu.com?www.xxxx.me 2.利用绕过限制urlhttps://www.baidu.comwww.xxxx.me 3.利用斜…...

【华为OD机试】单词接龙【2023 B卷|100分】

【华为OD机试】-真题 !!点这里!! 【华为OD机试】真题考点分类 !!点这里 !! 题目描述: 单词接龙的规则是:可用于接龙的单词首字母必须要前一个单词的尾字母相同; 当存在多个首字母相同的单词时,取长度最长的单词,如果长度也相等, 则取字典序最小的单词;已经参与接龙…...

如何优雅的实现无侵入性参数校验之spring-boot-starter-validation

在开发过程中&#xff0c;参数校验是一个非常重要的环节。但是&#xff0c;传统的参数校验方法往往需要在代码中手动添加大量的 if-else 语句&#xff0c;这不仅繁琐&#xff0c;而且容易出错。为了解决这个问题&#xff0c;我们可以使用无侵入性参数校验的方式来简化代码并提高…...

企业架构LNMP学习笔记27

Keepalived的配置补充&#xff1a; 脑裂&#xff08;裂脑&#xff09;&#xff1a;vip出现在了多台机器上。网络不通畅&#xff0c;禁用了数据包&#xff0c;主备服务器没法通讯&#xff0c;造成备服务器认为主服务器不可用&#xff0c;绑定VIP&#xff0c;主服务器VIP不会释放…...

品牌策划经理工作内容|工作职责|品牌策划经理做什么?

一位美国作家曾说过“品牌是一系列期望、记忆、故事和关系&#xff0c;他们共同构成了消费者最终原则一个产品或者服务的原因。” 所以&#xff0c;品牌经理这个岗位主要是创造感知价值主张&#xff0c;激发消费者购买这个品牌后带来的感知价值&#xff0c;这种回报的本质相对…...

【设计模式】三、概述分类+单例模式

文章目录 概述设计模式类型 单例模式饿汉式&#xff08;静态常量&#xff09;饿汉式&#xff08;静态代码块&#xff09;懒汉式(线程不安全)懒汉式(线程安全&#xff0c;同步方法)懒汉式(线程安全&#xff0c;同步代码块)双重检查静态内部类枚举单例模式在 JDK 应用的源码分析 …...

手把手教学 Springboot+ftp+下载图片

简单教学&#xff0c;复制即用的Ftp下载图片 引入配置包 <dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.3.1</version></dependency><dependency><grou…...

LaaS LLM as a service

LaaS LLM as a service 核心构成GPT 产业链如何进行商业化LLM(Large Language Model) 发展和趋势LLM(Large Language Model) 对于行业公司的分层LLM(Large Language Model) 的机遇和挑战 LaaS LLM as a service 核心构成 计算&#xff1a;算力模型&#xff1a;算法输入&…...

数据结构与算法(一)数组的相关概念和底层java实现

一、前言 从今天开始&#xff0c;笔者也开始从0学习数据结构和算法&#xff0c;但是因为这次学习比较捉急&#xff0c;所以记录的内容并不会过于详细&#xff0c;会从基础和底层代码实现以及力扣相关题目去写相关的文章&#xff0c;对于详细的概念并不会过多讲解 二、数组基础…...

歌曲推荐《最佳损友》

最佳损友 陈奕迅演唱歌曲 《最佳损友》是陈奕迅演唱的一首粤语歌曲&#xff0c;由黄伟文作词&#xff0c;Eric Kwok&#xff08;郭伟亮&#xff09;作曲。收录于专辑《Life Continues》中&#xff0c;发行于2006年6月15日。 2006年12月26日&#xff0c;该曲获得2006香港新城…...

多元共进|科技促进艺术发展,助力文化传承

科技发展助力文化和艺术的传播 融合传统与创新&#xff0c;碰撞独特魅力 一起来了解 2023 Google 开发者大会上 谷歌如何依托科技创新 推动艺术与文化连接 传承和弘扬传统文化 自 2011 年成立以来&#xff0c;谷歌艺术与文化致力于提供体验艺术和文化的新方式&#xff0c;从生成…...

Java集合(Collection、Iterator、Map、Collections)概述——Java第十三讲

前言 本讲我们将继续来讲解Java的其他重要知识点——Java集合。Java集合框架是Java编程语言中一个重要的部分,它提供了一套预定义的类和接口,供程序员使用数据结构来存储和操作一组对象。Java集合框架主要包括两种类型:一种是集合(Collection),存储一个元素列表,…...

topscoding主题库模板题

目录 模板题 【模板题】分因数&#xff08;P1101&#xff09; 【模板题】区间素数 III&#xff08;P1113&#xff09; 进制转换 III (任意转任意) &#xff08;P2463&#xff09; AB Problem&#xff08;高精度加法&#xff09; A-B Problem&#xff08;高精度减法&…...

Linux--进程间通讯--FIFO(open打开)

1. 什么是FIFO FIFO命名管道&#xff0c;也叫有名管道&#xff0c;来区分管道pipe。管道pipe只能用于有血缘关系的进程间通信&#xff0c;但通过FIFO可以实现不相关的进程之间交换数据。FIFO是Linux基础文件类型中的一种&#xff0c;但是FIFO文件在磁盘上没有数据块&#xff0c…...

哪里可以了解轻量的工作流引擎?

如果想要实现高效率的办公&#xff0c;可以使用轻量的工作流引擎低代码技术平台。随着工作量日益繁重起来&#xff0c;传统的办公制作方式已经无法满足现实需要的&#xff0c;采用轻量级的表格制作工具&#xff0c;就能在无形中缓解办公压力&#xff0c;创造更高效、灵活、优质…...

lvs负载均衡、LVS集群部署

四&#xff1a;LVS集群部署 lvs给nginx做负载均衡项目 218lvs&#xff08;DR 负载均衡器&#xff09; yum -y install ipvsadm&#xff08;安装这个工具来管理lvs&#xff09; 设置VIP192.168.142.120 创建ipvsadm的文件用来存放lvs的规则 定义策略 ipvsadm -C //清空现有…...

如何应对核心员工提离职?

最近一年互联网行情不好&#xff0c;很多大厂都在裁员&#xff0c;但裁员并不是不要人做事了。原来你这个岗位10个人做&#xff0c;企业有钱赚养得起&#xff0c;现在企业不怎么赚钱了&#xff0c;只能养4个人了。那么会有六个被裁掉。这时候对企业价值最大的4个人会被留下。也…...

建站系列(八)--- 本地开发环境搭建(WNMP)

目录 相关系列文章前言一、准备工作二、Nginx安装三、MySQL安装四、PHP安装及Nginx配置五、总结 相关系列文章 建站系列&#xff08;一&#xff09;— 网站基本常识 建站系列&#xff08;二&#xff09;— 域名、IP地址、URL、端口详解 建站系列&#xff08;三&#xff09;— …...

21天学会C++:Day8----范围for与nullptr

目录 ​编辑 1. 范围for 2. nullptr 1. 范围for 我们在写C语言循环遍历代码的时候&#xff0c;无论是用 for循环&#xff0c;while循环都需要考虑循环的起始条件&#xff0c;循环变量的递增逻辑&#xff0c;循环的结束条件。麻烦不说还可能会出错。 int main() {int arr[]…...

Android Wi-Fi 连接失败日志分析

1. Android wifi 关键日志总结 (1) Wi-Fi 断开 (CTRL-EVENT-DISCONNECTED reason3) 日志相关部分&#xff1a; 06-05 10:48:40.987 943 943 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid44:9b:c1:57:a8:90 reason3 locally_generated1解析&#xff1a; CTR…...

前端倒计时误差!

提示:记录工作中遇到的需求及解决办法 文章目录 前言一、误差从何而来?二、五大解决方案1. 动态校准法(基础版)2. Web Worker 计时3. 服务器时间同步4. Performance API 高精度计时5. 页面可见性API优化三、生产环境最佳实践四、终极解决方案架构前言 前几天听说公司某个项…...

Python爬虫实战:研究feedparser库相关技术

1. 引言 1.1 研究背景与意义 在当今信息爆炸的时代,互联网上存在着海量的信息资源。RSS(Really Simple Syndication)作为一种标准化的信息聚合技术,被广泛用于网站内容的发布和订阅。通过 RSS,用户可以方便地获取网站更新的内容,而无需频繁访问各个网站。 然而,互联网…...

Robots.txt 文件

什么是robots.txt&#xff1f; robots.txt 是一个位于网站根目录下的文本文件&#xff08;如&#xff1a;https://example.com/robots.txt&#xff09;&#xff0c;它用于指导网络爬虫&#xff08;如搜索引擎的蜘蛛程序&#xff09;如何抓取该网站的内容。这个文件遵循 Robots…...

12.找到字符串中所有字母异位词

&#x1f9e0; 题目解析 题目描述&#xff1a; 给定两个字符串 s 和 p&#xff0c;找出 s 中所有 p 的字母异位词的起始索引。 返回的答案以数组形式表示。 字母异位词定义&#xff1a; 若两个字符串包含的字符种类和出现次数完全相同&#xff0c;顺序无所谓&#xff0c;则互为…...

优选算法第十二讲:队列 + 宽搜 优先级队列

优选算法第十二讲&#xff1a;队列 宽搜 && 优先级队列 1.N叉树的层序遍历2.二叉树的锯齿型层序遍历3.二叉树最大宽度4.在每个树行中找最大值5.优先级队列 -- 最后一块石头的重量6.数据流中的第K大元素7.前K个高频单词8.数据流的中位数 1.N叉树的层序遍历 2.二叉树的锯…...

【7色560页】职场可视化逻辑图高级数据分析PPT模版

7种色调职场工作汇报PPT&#xff0c;橙蓝、黑红、红蓝、蓝橙灰、浅蓝、浅绿、深蓝七种色调模版 【7色560页】职场可视化逻辑图高级数据分析PPT模版&#xff1a;职场可视化逻辑图分析PPT模版https://pan.quark.cn/s/78aeabbd92d1...

AI+无人机如何守护濒危物种?YOLOv8实现95%精准识别

【导读】 野生动物监测在理解和保护生态系统中发挥着至关重要的作用。然而&#xff0c;传统的野生动物观察方法往往耗时耗力、成本高昂且范围有限。无人机的出现为野生动物监测提供了有前景的替代方案&#xff0c;能够实现大范围覆盖并远程采集数据。尽管具备这些优势&#xf…...

MySQL JOIN 表过多的优化思路

当 MySQL 查询涉及大量表 JOIN 时&#xff0c;性能会显著下降。以下是优化思路和简易实现方法&#xff1a; 一、核心优化思路 减少 JOIN 数量 数据冗余&#xff1a;添加必要的冗余字段&#xff08;如订单表直接存储用户名&#xff09;合并表&#xff1a;将频繁关联的小表合并成…...

【 java 虚拟机知识 第一篇 】

目录 1.内存模型 1.1.JVM内存模型的介绍 1.2.堆和栈的区别 1.3.栈的存储细节 1.4.堆的部分 1.5.程序计数器的作用 1.6.方法区的内容 1.7.字符串池 1.8.引用类型 1.9.内存泄漏与内存溢出 1.10.会出现内存溢出的结构 1.内存模型 1.1.JVM内存模型的介绍 内存模型主要分…...