Spring-1-透彻理解Spring XML的Bean创建--IOC
学习目标
上一篇文章我们介绍了什么是Spring,以及Spring的一些核心概念,并且快速快发一个Spring项目,实现IOC和DI,今天具体来讲解IOC
能够说出IOC的基础配置和Bean作用域
了解Bean的生命周期
能够说出Bean的实例化方式
一、Bean的基础配置
问题导入
问题1:在<bean>标签上如何配置别名?
问题2:Bean的默认作用范围是什么?如何修改?
1 Bean基础配置【重点】
配置说明

2 Bean别名配置
配置说明

注意事项:
获取bean无论是通过id还是name获取,如果无法获取到,将抛出异常NoSuchBeanDefinitionException
NoSuchBeanDefinitionException: No bean named 'studentDaoImpl' available
代码演示
【第0步】创建项目名称为10_2_IOC_Bean的maven项目
【第一步】导入Spring坐标
<dependencies><!--导入spring的坐标spring-context,对应版本是5.2.10.RELEASE--><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.3.15</version></dependency><!-- 导入junit的测试包 --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.8.2</version><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.28</version></dependency></dependencies>
【第二步】导入Student实体类
@Data
@ToString
@AllArgsConstructor
public class Student {private String name;private String address;private Integer age;private Integer status;
}
【第三步】定义Spring管理的类(接口)
-
StudentDao接口和StudentDaoImpl实现类
package com.zbbmeta.dao;public interface StudentDao {/*** 添加学生*/void save();
}
package com.zbbmeta.dao.impl;import com.zbbmeta.dao.StudentDao;public class StudentDaoImpl implements StudentDao {@Overridepublic void save() {System.out.println("DAO: 添加学生信息到数据库...");}
}
-
StudentService接口和StudentServiceImpl实现类
package com.zbbmeta.service;public interface StudentService {/*** 添加学生*/void save();
}
package com.zbbmeta.service.impl;import com.zbbmeta.dao.StudentDao;
import com.zbbmeta.dao.impl.StudentDaoImpl;
import com.zbbmeta.service.StudentService;public class StudentServiceImpl implements StudentService {//创建成员对象private StudentDao studentDao = new StudentDaoImpl();@Overridepublic void save() {}
}
【第四步】创建Spring配置文件在resources目录下,配置对应类作为Spring管理的bean对象
-
定义application.xml配置文件并配置StudentDaoImpl
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--目标:熟悉bean标签详细的属性应用--><!--name属性:可以设置多个别名,别名之间使用逗号,空格,分号等分隔--><bean name="studentDao2,abc studentDao3" class="com.zbbmeta.dao.impl.StudentDaoImpl" id="studentDao"></bean></beans>
注意事项:bean定义时id属性和name中名称不能有重复的在同一个上下文中(IOC容器中)不能重复
【第四步】根据容器别名获取Bean对象
package com.zbbmeta;import com.zbbmeta.dao.StudentDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class NameApplication {public static void main(String[] args) {/*** 从IOC容器里面根据别名获取对象执行*///1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="abc"对象StudentDao studentDao = (StudentDao) ac.getBean("abc");//3.执行对象方法studentDao.save();//4.关闭容器ac.close();}
}
打印结果

3 Bean作用范围配置【重点】
配置说明

扩展: scope的取值不仅仅只有singleton和prototype,还有request、session、application、 websocket ,表示创建出的对象放置在web容器(tomcat)对应的位置。比如:request表示保存到request域中。
代码演示
在application.xml中配置prototype格式
-
定义application.xml配置文件并配置StudentDaoImpl
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--目标:熟悉bean标签详细的属性应用--><!--scope属性:定义bean的作用范围,一共有5个singleton: 设置单例创建对象(推荐,也是默认值),好处:节省资源prototype: 设置多例创建对象,每次从IOC容器获取的时候都会创建对象,获取多次创建多次。request: 在web开发环境中,IOC容器会将对象放到request请求域中,对象存活的范围在一次请求内。请求开始创建对象,请求结束销毁对象session: 在web开发环境中,IOC容器会将对象放到session会话域中,对象存活的范围在一次会话内。会话开始开始创建对象,会话销毁对象销毁。global-session: 是多台服务器共享同一个会话存储的数据。--><bean class="com.zbbmeta.dao.impl.StudentDaoImpl" id="studentDao4" scope="prototype"></bean></beans>
根据容器别名获取Bean对象
package com.zbbmeta;import com.zbbmeta.dao.StudentDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class ScopeApplication {public static void main(String[] args) {/*** Bean的作用域范围演示*///1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象System.out.println("=========singleton(单例)模式=========");StudentDao studentDao = (StudentDao) ac.getBean("studentDao");StudentDao studentDao1 = (StudentDao) ac.getBean("studentDao");System.out.println("studentDao = " + studentDao);System.out.println("studentDao1 = " + studentDao1);System.out.println("=========prototype模式=========");StudentDao studentDao2 = (StudentDao) ac.getBean("studentDao4");StudentDao studentDao3 = (StudentDao) ac.getBean("studentDao4");System.out.println("studentDao2 = " + studentDao2);System.out.println("studentDao3 = " + studentDao3);//4.关闭容器ac.close();}
}
打印结果

注意:在我们的实际开发当中,绝大部分的Bean是单例的,也就是说绝大部分Bean不需要配置scope属性。
二、Bean的实例化
思考:Bean的实例化方式有几种?
2 实例化Bean的三种方式
2.1 构造方法方式【重点】
-
BookDaoImpl实现类
public class StudentDaoImpl implements StudentDao {public StudentDaoImpl() {System.out.println("Student dao constructor is running ....");}@Overridepublic void save() {System.out.println("DAO: 添加学生信息到数据库...");}
}
-
application.xml配置
<!--目标:讲解bean创建方式--><!--创建StudentDaoImpl对象方式1:默认调用类的无参构造函数创建--><bean id="studentDao" class="com.zbbmeta.dao.impl.StudentDaoImpl"/>
-
AppForInstanceBook测试类
public class OneApplication {public static void main(String[] args) {/*** 无参构造方式创建Bean*///1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象StudentDao studentDao = (StudentDao) ac.getBean("studentDao");//3.执行对象方法studentDao.save();//4.关闭容器ac.close();}
}
-
运行结果

注意:无参构造方法如果不存在,将抛出异常BeanCreationException
2.2 静态工厂方式
-
StudentDaoFactory工厂类
package com.zbbmeta.factory;import com.zbbmeta.dao.StudentDao;
import com.zbbmeta.dao.impl.StudentDaoImpl;public class StudentDaoFactory {
// 静态工厂创建对象public static StudentDao getStudentDao(){System.out.println("Student static factory setup....");return new StudentDaoImpl();}
}
-
applicationContext.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--目标:讲解bean创建方式--><!--创建StudentDaoImpl对象方式1:默认调用类的无参构造函数创建-->
<!-- <bean id="studentDao" class="com.zbbmeta.dao.impl.StudentDaoImpl"/>--><!--创建StudentDaoImpl对象方式2:调用静态工厂方法创建对象加入IOC容器class="com.zbbmeta.factory.StudentDaoFactory" 设置工厂类全名factory-method="getStudentDao" 调用工厂的静态方法
--><bean class="com.zbbmeta.factory.StudentDaoFactory" factory-method="getStudentDao" id="studentDao2"></bean></beans>
注意:测试前最好把之前使用Bean标签创建的对象进行注释
-
TwoApplication测试类
public class TwoApplication {public static void main(String[] args) {/*** 无参构造方式创建Bean*///1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象StudentDao studentDao = (StudentDao) ac.getBean("studentDao2");//3.执行对象方法studentDao.save();//4.关闭容器ac.close();}
}
-
运行结果

2.3 实例工厂方式
-
UserDao接口和UserDaoImpl实现类
//利用实例方法创建StudentDao对象public StudentDao getStudentDao2(){System.out.println("调用了实例工厂方法");return new StudentDaoImpl();}
-
StudentDaoFactory工厂类添加方法
//实例工厂创建对象
public class UserDaoFactory {public UserDao getUserDao(){return new UserDaoImpl();}
}
-
applicationContext.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--目标:讲解bean创建方式--><!--创建StudentDaoImpl对象方式1:默认调用类的无参构造函数创建-->
<!-- <bean id="studentDao" class="com.zbbmeta.dao.impl.StudentDaoImpl"/>--><!--创建StudentDaoImpl对象方式2:调用静态工厂方法创建对象加入IOC容器class="com.zbbmeta.factory.StudentDaoFactory" 设置工厂类全名factory-method="getStudentDao" 调用工厂的静态方法
-->
<!-- <bean class="com.zbbmeta.factory.StudentDaoFactory" factory-method="getStudentDao" id="studentDao2"></bean>--><!--创建BookDaoImpl对象方式3:调用实例工厂方法创建对象加入IOC容器class="com.itheima.factory.BookDaoFactory" 设置工厂类全名factory-method="getBookDao" 调用工厂的静态方法
--><!--第一步:创建工厂StudentDaoFactory对象--><bean class="com.zbbmeta.factory.StudentDaoFactory" id="studentDaoFactory"></bean><!--第一步:调用工厂对象的getStudentDao2()实例方法创建StudentDaoImpl对象加入IOC容器factory-bean="studentDaoFactory" 获取IOC容器中指定id值的对象factory-method="getStudentDao2" 如果配置了factory-bean,那么这里设置的就是实例方法名--><bean factory-bean="studentDaoFactory" factory-method="getStudentDao2" id="studentDao3"></bean></beans>
-
ThreeApplication测试类
package com.zbbmeta;import com.zbbmeta.dao.StudentDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class ThreeApplication {public static void main(String[] args) {/*** 无参构造方式创建Bean*///1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象StudentDao studentDao = (StudentDao) ac.getBean("studentDao3");//3.执行对象方法studentDao.save();//4.关闭容器ac.close();}
}
-
运行结果

三、Bean的生命周期【了解】
问题导入
问题1:多例的Bean能够配置并执行销毁的方法?
问题2:如何做才执行Bean销毁的方法?
1 生命周期相关概念介绍
-
生命周期:从创建到消亡的完整过程
-
bean生命周期:bean从创建到销毁的整体过程
-
bean生命周期控制:在bean创建后到销毁前做一些事情
1.1生命周期过程
- 初始化容器
-
创建对象(内存分配)
-
执行构造方法
-
执行属性注入(set操作)
-
执行bean初始化方法
-
- 使用bean
-
执行业务操作
-
- 关闭/销毁容器
-
执行bean销毁方法
-
2 代码演示
2.1 Bean生命周期控制
【第0步】创建项目名称为10_4_IOC_BeanLifeCycle的maven项目
【第一步】导入Spring坐标
<dependencies><!--导入spring的坐标spring-context,对应版本是5.2.10.RELEASE--><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.3.15</version></dependency><!-- 导入junit的测试包 --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.8.2</version><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.28</version></dependency></dependencies>
【第二步】导入Student实体类
@Data
@ToString
@AllArgsConstructor
public class Student {private String name;private String address;private Integer age;private Integer status;
}
【第三步】定义Spring管理的类(接口)
-
StudentDao接口和StudentDaoImpl实现类
package com.zbbmeta.dao;public interface StudentDao {/*** 添加学生*/void save();
}
package com.zbbmeta.dao.impl;import com.zbbmeta.dao.StudentDao;public class StudentDaoImpl implements StudentDao {public StudentDaoImpl(){System.out.println("Student Dao 的无参构造");}@Overridepublic void save() {System.out.println("DAO: 添加学生信息到数据库...");}public void init(){System.out.println("Student Dao 的初始化方法");}public void destroy(){System.out.println("Student Dao 的销毁方法");}
}
【第四步】创建Spring配置文件在resources目录下,配置对应类作为Spring管理的bean对象
-
定义application.xml配置文件并配置StudentDaoImpl
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--目标:创建StudentDaoImpl对象:设置生命周期方法init-method="init" 在对象创建后立即调用初始化方法destroy-method="destroy":在容器执行销毁前立即调用销毁的方法注意:只有单例对象才会运行销毁生命周期方法
--><bean class="com.zbbmeta.dao.impl.StudentDaoImpl" id="studentDao" init-method="init" destroy-method="destroy"></bean>
</beans>
【第四步】根据容器别名获取Bean对象
package com.zbbmeta;import com.zbbmeta.dao.StudentDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class LifeCycleApplication {public static void main(String[] args) {//1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象StudentDao studentDao = (StudentDao) ac.getBean("studentDao");//3.执行对象方法studentDao.save();//4.关闭容器ac.close();}
}
打印结果

3 Bean销毁时机
-
容器关闭前触发bean的销毁
- 关闭容器方式:
-
手工关闭容器 调用容器的
close()操作 -
注册关闭钩子(类似于注册一个事件),在虚拟机退出前先关闭容器再退出虚拟机 调用容器的
registerShutdownHook()操作
-
public class LifeCycleApplication {public static void main(String[] args) {//1.根据配置文件application.xml创建IOC容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("application.xml");//2.从IOC容器里面获取id="studentService"对象StudentDao studentDao = (StudentDao) ac.getBean("studentDao");//3.执行对象方法studentDao.save();//4.关闭容器
// ac.close();//注册关闭钩子函数,在虚拟机退出之前回调此函数,关闭容器ac.registerShutdownHook();}
}相关文章:
Spring-1-透彻理解Spring XML的Bean创建--IOC
学习目标 上一篇文章我们介绍了什么是Spring,以及Spring的一些核心概念,并且快速快发一个Spring项目,实现IOC和DI,今天具体来讲解IOC 能够说出IOC的基础配置和Bean作用域 了解Bean的生命周期 能够说出Bean的实例化方式 一、Bean的基础配置 …...
【JAVA】类和对象
作者主页:paper jie的博客 本文作者:大家好,我是paper jie,感谢你阅读本文,欢迎一建三连哦。 本文录入于《JAVASE语法系列》专栏,本专栏是针对于大学生,编程小白精心打造的。笔者用重金(时间和精…...
jenkins准备
回到目录 jenkins是一个开源的、提供友好操作界面的持续集成(CI)工具,主要用于持续、自动的构建/测试软件项目、监控外部任务的运行。Jenkins用Java语言编写,可在Tomcat等流行的servlet容器中运行,也可独立运行。通常与版本管理工具(SCM)、构…...
【Rust】Rust学习
文档:Rust 程序设计语言 - Rust 程序设计语言 简体中文版 (bootcss.com) 墙裂推荐这个文档 第一章入门 入门指南 - Rust 程序设计语言 简体中文版 第二章猜猜看游戏 猜猜看游戏教程 - Rust 程序设计语言 简体中文版 (bootcss.com) // 导入库 use std::io; use s…...
Linux 常用命令之配置环境变量 PATH
PATH是系统环境变量中的一种,同时将一些二进制文件的绝对路径追加进去,则在系统终端中可以发现这些路径下的文件。 一. 环境变量设置 export PATH<二进制文件的绝对路径>:$PATH 以下为结合实际例子的操作 1、临时设置 打开一个终端执行如下命令 e…...
flask-----蓝图
1.引入蓝图 flask都写在一个文件中,项目这样肯定不行,会导致循环导入的问题,分目录,分包,使用蓝图划分目录。 2.使用蓝图 步骤如下: -1 实例化得到一个蓝图对象-order_blueBlueprint(order,__name__,tem…...
学习左耳听风栏目90天——第一天 1-90(学习左耳朵耗子的工匠精神,对技术的热爱)【洞悉技术的本质,享受科技的乐趣】
洞悉技术的本质,享受科技的乐趣 第一篇,我的感受就是 耗叔是一个热爱技术,可以通过代码找到快乐的技术人。 作为it从业者,我们如何可以通过代码找到快乐呢?这是一个问题? 至少目前,我还没有这种…...
后端登录安全的一种思路
PS:作者是小白能接触到的就只会这样写。勿喷。 前提 思路: 结合io流将登录token存储到配置文件中,不将token存储到浏览器端,从而避免盗取。 下面jwt的学习可以参考下这个: JWT --- 入门学习_本郡主是喵的博客-CSDN博客 JWT工具类 Component public class JWTtU…...
【深度学习_TensorFlow】激活函数
写在前面 上篇文章我们了解到感知机使用的阶跃函数和符号函数,它们都是非连续,导数为0的函数: 建议回顾上篇文章,本篇文章将介绍神经网络中的常见激活函数,这些函数都是平滑可导的,适合于梯度下降算法。 写…...
机器学习笔记之优化算法(七)线搜索方法(步长角度;非精确搜索;Wolfe Condition)
机器学习笔记之优化算法——线搜索方法[步长角度,非精确搜索,Wolfe Condition] 引言回顾: Armijo \text{Armijo} Armijo准则及其弊端 Glodstein \text{Glodstein} Glodstein准则及其弊端 Wolfe Condition \text{Wolfe Condition} Wolfe Condi…...
十四.redis哨兵模式
redis哨兵模式 1.概述2.测试3.哨兵模式优缺点 redis哨兵模式基础是主从复制 1.概述 主从切换的技术方法:当主节点服务器宕机后,需要手动把一台从服务器切换为主服务器,这就需要人工干预,费时费力,还会造成一段时间内服…...
采用UWB技术开发的智慧工厂人员定位系统源码【UWB定位基站、卡牌】
UWB (ULTRA WIDE BAND, UWB) 技术是一种无线载波通讯技术,它不采用正弦载波,而是利用纳秒级的非正弦波窄脉冲传输数据,因此其所占的频谱范围很宽。UWB定位系统依托在移动通信,雷达,微波电路,云计算与大数据…...
当你软件测试遇上加密接口,是不是就不能测了?
相信大家在工作中做接口测试的时候,肯定会遇到一个场景,那就是你们的软件,密码是加密存储的。 那么这样的话,我们在执行接口的时候,对于密码的处理就开始头疼了。 所以,本文将使用jmeter这款java开源的接…...
Flink
Flink(Apache Flink)是一个开源的分布式流处理引擎和批处理框架。它是由 Apache 软件基金会维护的项目,旨在处理大规模数据的实时流式处理和批处理任务。Flink 提供了强大的流处理和批处理功能,具有低延迟、高吞吐量和高容错性&am…...
python入门常用操作
python常用操作 1、ndarry数组的切片2、print用法2.1格式化输出format2.2字符串格式化输出 3、均值滤波函数 1、ndarry数组的切片 例如一个5列的ndarry数组,想要获取第2列和第3列数据,可以用 #(1)用法1 data[:,1:3],…...
SpringBoot复习:(21)自定义ImportBeanDefinitionRegistrar
要达到的目的:将某个包下使用了某个自定义注解(比如MyClassMapper)的类注册到Spring 容器。 一、自定义注解: package com.example.demo.service;import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;Rete…...
小黑子—JavaWeb:第五章 - JSP与会话跟踪技术
JavaWeb入门5.0 1. JSP1.1 JSP快速入门1.2 JSP原理1.3 JSP脚本1.3.1 JSP缺点 1.4 EL 表达式1.5 JSTL 标签1.5.1 JSTL 快速入门1.5.1 - I JSTL标签if1.5.1 - II JSTL标签forEach 1.6 MVC模式1.7 三层架构1.8 实现案例1.8.1 环境准备1.8.2 查询所有1.8.3 添加数据1.8.4 修改1.8.4…...
Python - 【socket】 客户端client重连处理简单示例Demo(一)
一. 前言 在Python中,使用socket进行网络通信时,如果连接断开,可以通过以下步骤实现重连处理 二. 示例代码 1. 定义一个函数,用于建立socket连接 import socketdef connect_socket(host, port):while True:try:# 建立socket连…...
Redis 基础
1.定义 Redis 是一个高性能的key-value数据库,key是字符串类型。 2.核心特点: 单进程: Redis的服务器程序采用的是单进程模型来处理客户端的请求。对读写时间的响 应是通过对epoll函数的包装来做到的。 3.数据类型: 键的类型…...
【0805作业】Linux中 AB终端通过两根有名管道进行通信聊天(半双工)
作业一:打开两个终端,要求实现AB进程对话【两根管道】 打开两个终端,要求实现AB进程对话 A进程先发送一句话给B进程,B进程接收后打印B进程再回复一句话给A进程,A进程接收后打印重复1.2步骤,当收到quit后&am…...
超短脉冲激光自聚焦效应
前言与目录 强激光引起自聚焦效应机理 超短脉冲激光在脆性材料内部加工时引起的自聚焦效应,这是一种非线性光学现象,主要涉及光学克尔效应和材料的非线性光学特性。 自聚焦效应可以产生局部的强光场,对材料产生非线性响应,可能…...
多场景 OkHttpClient 管理器 - Android 网络通信解决方案
下面是一个完整的 Android 实现,展示如何创建和管理多个 OkHttpClient 实例,分别用于长连接、普通 HTTP 请求和文件下载场景。 <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas…...
Cesium1.95中高性能加载1500个点
一、基本方式: 图标使用.png比.svg性能要好 <template><div id"cesiumContainer"></div><div class"toolbar"><button id"resetButton">重新生成点</button><span id"countDisplay&qu…...
深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法
深入浅出:JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中,随机数的生成看似简单,却隐藏着许多玄机。无论是生成密码、加密密钥,还是创建安全令牌,随机数的质量直接关系到系统的安全性。Jav…...
连锁超市冷库节能解决方案:如何实现超市降本增效
在连锁超市冷库运营中,高能耗、设备损耗快、人工管理低效等问题长期困扰企业。御控冷库节能解决方案通过智能控制化霜、按需化霜、实时监控、故障诊断、自动预警、远程控制开关六大核心技术,实现年省电费15%-60%,且不改动原有装备、安装快捷、…...
【CSS position 属性】static、relative、fixed、absolute 、sticky详细介绍,多层嵌套定位示例
文章目录 ★ position 的五种类型及基本用法 ★ 一、position 属性概述 二、position 的五种类型详解(初学者版) 1. static(默认值) 2. relative(相对定位) 3. absolute(绝对定位) 4. fixed(固定定位) 5. sticky(粘性定位) 三、定位元素的层级关系(z-i…...
转转集团旗下首家二手多品类循环仓店“超级转转”开业
6月9日,国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解,“超级…...
ESP32 I2S音频总线学习笔记(四): INMP441采集音频并实时播放
简介 前面两期文章我们介绍了I2S的读取和写入,一个是通过INMP441麦克风模块采集音频,一个是通过PCM5102A模块播放音频,那如果我们将两者结合起来,将麦克风采集到的音频通过PCM5102A播放,是不是就可以做一个扩音器了呢…...
【论文笔记】若干矿井粉尘检测算法概述
总的来说,传统机器学习、传统机器学习与深度学习的结合、LSTM等算法所需要的数据集来源于矿井传感器测量的粉尘浓度,通过建立回归模型来预测未来矿井的粉尘浓度。传统机器学习算法性能易受数据中极端值的影响。YOLO等计算机视觉算法所需要的数据集来源于…...
Java 加密常用的各种算法及其选择
在数字化时代,数据安全至关重要,Java 作为广泛应用的编程语言,提供了丰富的加密算法来保障数据的保密性、完整性和真实性。了解这些常用加密算法及其适用场景,有助于开发者在不同的业务需求中做出正确的选择。 一、对称加密算法…...
