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

Spring框架体系及Spring IOC思想

目录

  • Spring简介
  • Spring体系结构
  • SpringIOC
  • 控制反转思想
  • 自定义对象容器
  • Spring实现IOC
  • Spring容器类型
  • 容器接口
  • 容器实现类
  • 对象的创建方式
  • 使用构造方法
  • 使用工厂类的方法
  • 使用工厂类的静态方法
  • 对象的创建策略
  • 对象的销毁时机
  • 生命周期方法
  • 获取Bean对象的方式
  • 通过id/name获取
  • 通过类型获取
  • 通过类型+id/name获取

Spring简介

在这里插入图片描述

Spring是一个开源框架,为简化企业级开发而生。它以IOC(控制反转)和AOP(面向切面)为思想内核,提供了控制层SpringMVC、数据层SpringData、服务层事务管理等众多技术,并可以整合众多第三方框架。

Spring将很多复杂的代码变得优雅简洁,有效的降低代码的耦合度,极大的方便项目的后期维护、升级和扩展。

Spring官网地址:https://spring.io/

Spring体系结构

在这里插入图片描述

Spring框架根据不同的功能被划分成了多个模块,这些模块可以满足一切企业级应用开发的需求,在开发过程中可以根据需求有选择性地使用所需要的模块。

  • Core Container:Spring核心模块,任何功能的使用都离不开该模块,是其他模块建立的基础。
  • Data Access/Integration:该模块提供了数据持久化的相应功能。
  • Web:该模块提供了web开发的相应功能。
  • AOP:提供了面向切面编程实现
  • Aspects:提供与AspectJ框架的集成,该框架是一个面向切面编程框架。
  • Instrumentation:提供了类工具的支持和类加载器的实现,可以在特定的应用服务器中使用。
  • Messaging:为Spring框架集成一些基础的报文传送应用
  • Test:提供与测试框架的集成

SpringIOC

在这里插入图片描述

控制反转思想

IOC(Inversion of Control) :程序将创建对象的权利交给框架。

之前在开发过程中,对象实例的创建是由调用者管理的,代码如下:

public interface StudentDao {// 根据id查询学生Student findById(int id);
}public class StudentDaoImpl implements StudentDao{@Overridepublic Student findById(int id) {// 模拟从数据库查找出学生return new Student(1,"张三","北京");}
}public class StudentService {public Student findStudentById(int id){// 此处就是调用者在创建对象StudentDao studentDao = new StudentDaoImpl();return studentDao.findById(1);}
}

这种写法有两个缺点:

  1. 浪费资源:StudentService调用方法时即会创建一个对象,如果不断调用方法则会创建大量StudentDao对象。
  2. 代码耦合度高:假设随着开发,我们创建了StudentDao另一个更加完善的实现类StudentDaoImpl2,如果在StudentService中想使用StudentDaoImpl2,则必须修改源码。

而IOC思想是将==创建对象的权利交给框架==,框架会帮助我们创建对象,分配对象的使用,控制权由程序代码转移到了框架中,控制权发生了反转,这就是Spring的IOC思想。而IOC思想可以完美的解决以上两个问题。

自定义对象容器

接下来我们通过一段代码模拟IOC思想。创建一个集合容器,先将对象创建出来放到容器中,需要使用对象时,只需要从容器中获取对象即可,而不需要重新创建,此时容器就是对象的管理者。

  1. 创建实体类

    public class Student {private int id;private String name;private String address;// 省略getter/setter/构造方法/tostring
    }
    
  2. 创建Dao接口和实现类

    public interface StudentDao {// 根据id查询学生Student findById(int id);
    }public class StudentDaoImpl implements StudentDao{@Overridepublic Student findById(int id) {// 模拟从数据库查找出学生return new Student(1,"张三","北京");}
    }public class StudentDaoImpl2 implements StudentDao{@Overridepublic Student findById(int id) {// 模拟根据id查询学生System.out.println("新方法!!!");return new Student(1,"张三","北京");}
    }
    
  3. 创建配置文件bean.properties,该文件中定义管理的对象

    studentDao=com.Spring.dao.StudentDaoImpl
    
  4. 创建容器管理类,该类在类加载时读取配置文件,将配置文件中配置的对象全部创建并放入容器中。

    public class Container {static Map<String,Object> map = new HashMap();static {// 读取配置文件InputStream is = Container.class.getClassLoader().getResourceAsStream("bean.properties");Properties properties = new Properties();try {properties.load(is);} catch (IOException e) {e.printStackTrace();}// 遍历配置文件的所有配置Enumeration<Object> keys = properties.keys();while (keys.hasMoreElements()){String key = keys.nextElement().toString();String value = properties.getProperty(key);try {// 创建对象Object o = Class.forName(value).newInstance();// 将对象放入集合中map.put(key,o);} catch (Exception e) {e.printStackTrace();}}}// 从容器中获取对象public static Object getBean(String key){return map.get(key);}
    }
    
  5. 创建Dao对象的调用者StudentService

    public class StudentService {public Student findStudentById(int id){// 从容器中获取对象StudentDao studentDao = (StudentDao) Container.getBean("studentDao");System.out.println(studentDao.hashCode());return studentDao.findById(id);}
    }
    
  6. 测试StudentService

    public class Test {public static void main(String[] args) {StudentService studentService = new StudentService();System.out.println(studentService.findStudentById(1));System.out.println(studentService.findStudentById(1));}
    }
    

测试结果:

  1. StudentService从容器中每次拿到的都是同一个StudentDao对象,节约了资源。

  2. 如果想使用StudentDaoImpl2对象,只需要修改bean.properties的内容为

    studentDao=com.Spring.dao.StudentDaoImpl2
    

    即可,无需修改Java源码。

Spring实现IOC

接下来我们使用Spring实现IOC,Spring内部也有一个容器用来管理对象。

  1. 创建Maven工程,引入依赖

    <dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.3.13</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency>
    </dependencies>
    
  2. 创建POJO类、Dao类和接口

    public class Student {private int id;private String name;private String address;// 省略getter/setter/构造方法/tostring
    }public interface StudentDao {// 根据id查询学生Student findById(int id);
    }public class StudentDaoImpl implements StudentDao{@Overridepublic Student findById(int id) {// 模拟从数据库查找出学生return new Student(1,"张三","北京");}
    }
    
  3. 编写xml配置文件,配置文件中配置需要Spring帮我们创建的对象。

    <?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="studentDao" class="com.Spring.dao.StudentDaoImpl"></bean></beans>
    
  4. 测试从Spring容器中获取对象。

    public class TestContainer {@Testpublic void t1(){// 创建Spring容器ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");// 从容器获取对象StudentDao studentDao1 = (StudentDao) ac.getBean("studentDao");StudentDao studentDao2 = (StudentDao) ac.getBean("studentDao");System.out.println(studentDao1.hashCode());System.out.println(studentDao2.hashCode());System.out.println(studentDao1.findById(1));}
    }
    

Spring容器类型

容器接口
  • BeanFactory:BeanFactory是Spring容器中的顶层接口,它可以对Bean对象进行管理。

  • ApplicationContext:ApplicationContext是BeanFactory的子接口。它除了继承 BeanFactory的所有功能外,还添加了对国际化、资源访问、事件传播等方面的良好支持。

    ApplicationContext有以下三个常用实现类:

容器实现类
  • ClassPathXmlApplicationContext:该类可以从项目中读取配置文件
  • FileSystemXmlApplicationContext:该类从磁盘中读取配置文件
  • AnnotationConfigApplicationContext:使用该类不读取配置文件,而是会读取注解
@Test
public void t2(){// 创建spring容器//     ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");ApplicationContext ac = new FileSystemXmlApplicationContext("C:\\Users\\a\\IdeaProjects\\spring_demo\\src\\main\\resources\\bean.xml");// 从容器中获取对象StudentDao userDao = (StudentDao) ac.getBean("studentDao");System.out.println(userDao);System.out.println(userDao.findById(1));
}

对象的创建方式

Spring会帮助我们创建bean,那么它底层是调用什么方法进行创建的呢?

使用构造方法

Spring默认使用类的空参构造方法创建bean:

// 假如类没有空参构造方法,将无法完成bean的创建
public class StudentDaoImpl implements StudentDao{public StudentDaoImpl(int a){}@Overridepublic Student findById(int id) {// 模拟根据id查询学生return new Student(1,"张三","北京");}
}
使用工厂类的方法

Spring可以调用工厂类的方法创建bean:

  1. 创建工厂类,工厂类提供创建对象的方法:

    public class StudentDaoFactory {public StudentDao getStudentDao(){return new StudentDaoImpl(1);}
    }
    
  2. 在配置文件中配置创建bean的方式为工厂方式。

    <!--  id:工厂对象的id,class:工厂类  -->
    <bean id="studentDaoFactory" class="com.Spring.dao.StudentDaoFactory"></bean>
    <!--  id:bean对象的id,factory-bean:工厂对象的id,factory-method:工厂方法 -->
    <bean id="studentDao" factory-bean="studentDaoFactory" factory-method="getStudentDao"></bean>
    
  3. 测试

使用工厂类的静态方法

Spring可以调用工厂类的静态方法创建bean:

  1. 创建工厂类,工厂提供创建对象的静态方法。

    public class StudentDaoFactory2 {public static StudentDao getStudentDao2() {return new StudentDaoImpl();}
    }
    
  2. 在配置文件中配置创建bean的方式为工厂静态方法。

    <!-- id:bean的id  class:工厂全类名 factory-method:工厂静态方法  -->
    <bean id="studentDao" class="com.Spring.dao.StudentDaoFactory2" factory-method="getStudentDao2"></bean>
    
  3. 测试

对象的创建策略

Spring通过配置<bean>中的scope属性设置对象的创建策略,共有五种创建策略:

  • singleton:单例,默认策略。整个项目只会创建一个对象,通过<bean>中的lazy-init属性可以设置单例对象的创建时机:

    lazy-init="false"(默认):立即创建,在容器启动时会创建配置文件中的所有Bean对象。

    lazy-init="true":延迟创建,第一次使用Bean对象时才会创建。

    配置单例策略:

    <!--   <bean id="studentDao" class="com.Spring.dao.StudentDaoImpl2" scope="singleton" lazy-init="true"></bean>-->
    <bean id="studentDao" class="com.Spring.dao.StudentDaoImpl2" scope="singleton" lazy-init="false">
    </bean>
    

    测试单例策略:

    // 为Bean对象的类添加构造方法
    public StudentDaoImpl2(){System.out.println("创建StudentDao!!!");
    }
    @Test
    public void t2(){// 创建Spring容器ApplicationContext ac = new ClassPathXmlApplicationContext("bean1.xml");// 从容器获取对象StudentDao studentDao1 = (StudentDao) ac.getBean("studentDao");StudentDao studentDao2 = (StudentDao) ac.getBean("studentDao");StudentDao studentDao3 = (StudentDao) ac.getBean("studentDao");System.out.println(studentDao1.hashCode());System.out.println(studentDao2.hashCode());System.out.println(studentDao3.hashCode());
    }
    
  • prototype:多例,每次从容器中获取时都会创建对象。

    <!-- 配置多例策略 -->
    <bean id="studentDao"   class="com.Spring.dao.StudentDaoImpl2" scope="prototype"></bean>
    
  • request:每次请求创建一个对象,只在web环境有效。

  • session:每次会话创建一个对象,只在web环境有效。

  • gloabal-session:一次集群环境的会话创建一个对象,只在web环境有效。

对象的销毁时机

对象的创建策略不同,销毁时机也不同:

  • singleton:对象随着容器的销毁而销毁。
  • prototype:使用JAVA垃圾回收机制销毁对象。
  • request:当处理请求结束,bean实例将被销毁。
  • session:当HTTP Session最终被废弃的时候,bean也会被销毁掉。
  • gloabal-session:集群环境下的session销毁,bean实例也将被销毁。

生命周期方法

Bean对象的生命周期包含创建——使用——销毁,Spring可以配置Bean对象在创建和销毁时自动执行的方法:

  1. 定义生命周期方法

    public class StudentDaoImpl2 implements StudentDao{// 创建时自动执行的方法public void init(){System.out.println("创建StudentDao!!!");}// 销毁时自动执行的方法public void destory(){System.out.println("销毁StudentDao!!!");}
    }
    
  2. 配置生命周期方法

    <!-- init-method:创建对象时执行的方法  destroy-method:销毁对象时执行的方法  -->
    <bean id="studentDao" class="com.Spring.dao.StudentDaoImpl2" scope="singleton"init-method="init" destroy-method="destory"></bean>
    
  3. 测试

    @Test
    public void t3(){// 创建Spring容器ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean1.xml");// 销毁Spring容器,ClassPathXmlApplicationContext才有销毁容器的方法ac.close();
    }
    

获取Bean对象的方式

Spring有多种获取容器中对象的方式:

通过id/name获取
  1. 配置文件

    <bean name="studentDao" class="com.Spring.dao.StudentDaoImpl2"></bean>||
    <bean id="studentDao" class="com.Spring.dao.StudentDaoImpl2"></bean>
    
  2. 获取对象

    StudentDao studentDao = (StudentDao) ac.getBean("studentDao");
    
通过类型获取
  1. 配置文件

    <bean name="studentDao" class="com.Spring.dao.StudentDaoImpl2"></bean>
    
  2. 获取对象

    StudentDao studentDao2 = ac.getBean(StudentDao.class);
    

    可以看到使用类型获取不需要强转。

通过类型+id/name获取

虽然使用类型获取==不需要强转==,但如果在容器中有一个接口的多个实现类对象,则获取时会报错,此时需要使用类型+id/name获取

  1. 配置文件

    <bean name="studentDao" class="com.Spring.dao.StudentDaoImpl2"></bean>
    <bean name="studentDao1" class="com.Spring.dao.StudentDaoImpl"></bean>
    
  2. 获取对象

    StudentDao studentDao2 = ac.getBean("studentDao",StudentDao.class);
    

相关文章:

Spring框架体系及Spring IOC思想

目录 Spring简介Spring体系结构SpringIOC控制反转思想自定义对象容器Spring实现IOCSpring容器类型容器接口容器实现类对象的创建方式使用构造方法使用工厂类的方法使用工厂类的静态方法对象的创建策略对象的销毁时机生命周期方法获取Bean对象的方式通过id/name获取通过类型获取…...

WT588F02B-8S语音芯片:16位DSP技术引领个性化功能产品新时代

随着科技的快速发展&#xff0c;语音芯片作为人机交互的核心组件&#xff0c;在各个领域的应用越来越广泛。唯创知音推出的WT588F02B-8S语音芯片&#xff0c;以其强大的16位DSP技术和丰富的内置资源&#xff0c;正成为行业内的翘楚。 首先&#xff0c;唯创知音WT588F02B-8S是一…...

数字逻辑电路基础-时序逻辑电路之移位寄存器

文章目录 一、移位寄存器定义二、verilog源码三、仿真结果 一、移位寄存器定义 移位寄存器定义 A shift register is a type of digital circuit using a cascade of flip flops where the output of one flip-flop is connected to the input of the next. 移位寄存器是一种将…...

DEM分析

一、实验名称&#xff1a; DEM分析 二、实验目的&#xff1a; 通过本实验练习&#xff0c;掌握DEM的建立与应用基本方法。 三、实验内容和要求&#xff1a; 实验内容&#xff1a; 利用ARCGIS软件相关分析工具及实验数据&#xff0c;创建DEM&#xff0c;并计算相应坡度的区…...

全面探讨HTTP协议从0.9到3.0版本的发展和特点

前言&#xff1a; 最近的几场面试都问到了http的相关知识点&#xff0c;博主在此结合书籍和网上资料做下总结。本篇文章讲收录到秋招专题&#xff0c;该专栏比较适合刚入坑Java的小白以及准备秋招的大佬阅读。 如果文章有什么需要改进的地方欢迎大佬提出&#xff0c;对大佬有帮…...

中通快递查询入口,根据物流更新量筛选出需要的单号记录

批量中通快递单号的物流信息&#xff0c;根据物流更新量将需要的单号记录筛选出来。 所需工具&#xff1a; 一个【快递批量查询高手】软件 中通快递单号若干 操作步骤&#xff1a; 步骤1&#xff1a;运行【快递批量查询高手】软件&#xff0c;并登录 步骤2&#xff1a;点击主…...

Arraylist案例

Arraylist是使用最频繁的一个集合&#xff0c;它与数组类似&#xff0c;不同之处在于它可以动态改变长度&#xff0c;不够了可以扩容。 案例&#xff1a; 我的思考&#xff1a; 首先多个菜品信息可以用Arraylist 来存储&#xff0c;那我们需要再创建一个菜品类Food&#xff0…...

『heqingchun-Ubuntu系统+x86架构+配置编译安装使用yolov5-6.0+带有TensorRT硬件加速+C++部署』

Ubuntu系统x86架构配置编译安装使用yolov5-6.0带有TensorRT硬件加速C部署 一、准备文件 1.yolov5-6.0.zip 官网下载 网址&#xff1a; https://github.com/ultralytics/yolov5/tree/v6.0操作&#xff1a; 点击"Code"下的"Download ZIP" 下载得到yolov5…...

优秀的员工成为公司的管理者之后,为何表现平庸?因为他们缺乏这些思维

在企业的实践中&#xff0c;我们发现平时能力最强的员工&#xff0c;在被提拔到管理层之后就慢慢变得平庸了&#xff0c;再也不是以前那个无所不能的“企业能人”了&#xff0c;甚至在一些事情的处理上还会有些笨拙。面对这种情况&#xff0c;我们一定会感觉很疑惑&#xff0c;…...

MySQL简单介绍

简单了解MySQL MySQL语句分类 SQL语句分类 DDL&#xff1a;数据定义语句 create表&#xff0c;库.….] DML&#xff1a;数据操作语句 [增加insert&#xff0c;修改 update&#xff0c;删除delete] DQL&#xff1a;数据查询语句 [select] DCL&#xff1a;数据控制语句 …...

【开源】基于JAVA的天然气工程业务管理系统

项目编号&#xff1a; S 021 &#xff0c;文末获取源码。 \color{red}{项目编号&#xff1a;S021&#xff0c;文末获取源码。} 项目编号&#xff1a;S021&#xff0c;文末获取源码。 目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块三、使用角色3.1 施工人员3.2 管理员 四…...

虚幻学习笔记—点击场景3D物体的两种处理方式

一、前言 本文使用的虚幻引擎为5.3.2&#xff0c;两种方式分别为&#xff1a;点击根物体和精准点击目标物体。 二、实现 2.1、玩家控制器中勾选鼠标点击事件&#xff1a;这一步很重要&#xff0c;如图2.1.1所示&#xff1a;在自定义玩家控制器中勾 图2.1.1 选该项&#xff0c…...

AIGC|LangChain新手入门指南,5分钟速读版!

如果你用大语言模型来构建AI应用&#xff0c;那你一定不可能绕过LangChain,LangChain是现在最热门的AI应用框架之一&#xff0c;去年年底才刚刚发布&#xff0c;它在github上已经有了4.6万颗星的点赞了&#xff0c;在github社区上&#xff0c;每天都有众多大佬&#xff0c;用它…...

探索 Linux vim/vi 编辑器:介绍、模式以及基本操作演示

&#x1f490;作者&#xff1a;insist-- &#x1f490;个人主页&#xff1a;insist-- 的个人主页 理想主义的花&#xff0c;最终会盛开在浪漫主义的土壤里&#xff0c;我们的热情永远不会熄灭&#xff0c;在现实平凡中&#xff0c;我们终将上岸&#xff0c;阳光万里 ❤️欢迎点…...

Centos 7 在线安装(RPM) PostgreSQL 14 15 16

目录 一、官网下载地址二、检查系统是否安装其他版本PostgreSQL数据库三、安装数据库四、配置数据库(默认方式一)4.1初始化用户密码4.2修改postgresql.conf文件4.3修改pg_hba.conf文件五、修改默认存储路径六、配置防火墙七、生产环境优化(待完善)八、启用SSL加密(待验证)九…...

如何在gitlab上使用hooks

参考链接&#xff1a;gitlab git hooks 1. Git Hook 介绍 与许多其他版本控制系统一样&#xff0c;Git 有一种方法可以在发生某些重要操作时&#xff0c;触发自定义脚本&#xff0c;即 Git Hook&#xff08;Git 钩子&#xff09;。 当我们初始化一个项目之后&#xff0c;.git…...

【点云surface】 凹包重构

1 处理过程可视化 原始数据 直通滤波过滤后 pcl::ProjectInliers结果 pcl::ExtractIndices结果 凹包结果 凸包结果 2 处理过程分析&#xff1a; 原始点云 ---> 直通滤波 --> pcl::SACSegmentation分割出平面 -->pcl::ProjectInliers投影 --> pcl::ConcaveHull凹包…...

Linux sed命令

目录 一. 去除单个指定文本的换行符二. 去除多个指定文本的换行符三. 抽取出指定数据3.1 分别抽取SPLREQUEST和SPLEND的数据3.2 通过join命令将文件合并3.3 抽取出指定的数据3.4 去除换行符&#xff0c;整合数据为一行 一. 去除单个指定文本的换行符 &#x1f449; info.txt …...

Nginx反向代理实现负载均衡+Keepalive实现高可用

目录 实现负载均衡 实现高可用 实现负载均衡 Nginx的几种负载均衡算法&#xff1a; 1.轮询&#xff08;默认&#xff09; 每个请求按照时间顺序逐一分配到下游的服务节点&#xff0c;如果其中某一节点故障&#xff0c;nginx 会自动剔除故障系统使用户使用不受影响。 2.权重…...

实用高效 无人机光伏巡检系统助力电站可持续发展

近年来&#xff0c;我国光伏发电行业规模日益壮大&#xff0c;全球领先地位愈发巩固。为解决光伏电站运维中的难题&#xff0c;浙江某光伏电站与复亚智能达成战略合作&#xff0c;共同推出全自动无人机光伏巡检系统&#xff0c;旨在提高发电效率、降低运维成本&#xff0c;最大…...

wan2.1-vae部署方案:CSDN GPU云+自定义域名+HTTPS反向代理配置

wan2.1-vae部署方案&#xff1a;CSDN GPU云自定义域名HTTPS反向代理配置 1. 平台介绍 muse/wan2.1-vae是基于Qwen-Image-2512模型的AI图像生成平台&#xff0c;能够根据中英文提示词生成高质量、高分辨率的图像。这个平台特别适合需要快速生成专业级图像的用户&#xff0c;无…...

Windows Server 配置与管理——第4章:磁盘管理

目录 4.1 项目背景 4.2 相关知识 1. 概念和术语 2. 基本磁盘 3. 动态磁盘 4. 磁盘配额 4.3 项目过程 4.3.1 任务 1 基本磁盘管理 1. 扩展磁盘空间 2. 新建简单卷 3. 删除简单卷 4. 添加新磁盘 4.3.2 任务 2 动态磁盘管理 1. 将基本磁盘转换成动态磁盘 2. 创建、…...

【GraalVM静态镜像内存优化终极指南】:20年JVM专家亲授3大内存压缩技法,启动速度提升87%的私密实践

第一章&#xff1a;GraalVM静态镜像内存优化快速接入全景概览GraalVM 静态镜像&#xff08;Native Image&#xff09;通过提前编译&#xff08;AOT&#xff09;将 Java 应用编译为独立、无 JVM 依赖的原生可执行文件&#xff0c;在启动速度与内存占用方面具备显著优势。然而&am…...

C/C++头文件防护:#pragma once原理与实践

1. #pragma once 的基本概念与作用在C/C项目开发中&#xff0c;头文件包含管理是个看似简单却暗藏玄机的问题。我第一次意识到它的重要性是在参与一个跨平台嵌入式项目时&#xff0c;某个模块因为头文件重复包含导致的结构体重定义错误&#xff0c;让整个团队排查了整整两天。而…...

OCAD应用:多重转换式断续变焦系统设计

多组转换型变焦系统可以实现多档断续变焦。设计时同时设计多重可打入活动组&#xff0c;在打入时随意转换。多组转换型的活动组可以放置在会聚光路中也可以在平行光路中。选择在平行光路中&#xff0c;可利用活动组的无焦性来回倒置获得放大缩小两种不同变焦效果。 图1.多组转…...

Boodskap数字孪生Arduino客户端库深度解析

1. Boodskap IoT Digital Twin Arduino客户端库深度解析Boodskap IoT Digital Twin Arduino Client Library 是一款面向嵌入式边缘设备的轻量级物联网通信中间件&#xff0c;专为将Arduino生态&#xff08;尤其是ESP32系列&#xff09;传感器节点快速接入Boodskap Twinned数字孪…...

ELF与镜像文件格式解析及二进制工具链实践

1. 文件格式基础概念解析在软件开发与系统底层交互过程中&#xff0c;我们经常会遇到各种不同类型的二进制文件。这些文件虽然都以二进制形式存储&#xff0c;但各自具有完全不同的结构和用途。理解它们的区别对于程序编译、链接、调试以及系统级开发都至关重要。ELF&#xff0…...

Java 线程、进程、CPU缓存、MESI

一、进程&线程 1、什么是进程&#xff08;process&#xff09; 进程是操作系统中运行的一个任务&#xff08;一个应用程序运行在一个进程中&#xff09;。 进程是一块包含了某些资源的内存区域&#xff0c;操作系统利用进程把它的工作划分为一些功能单元。 进程中包含的…...

OpenAI API 报错 insufficient_quota 怎么办?4 种方案实测,最后一种最省心

上周五晚上十一点半&#xff0c;我正用 GPT-5 的 API 跑一个批量文本分类任务&#xff0c;跑到一半控制台突然刷屏红色报错&#xff1a;You exceeded your current quota, please check your plan and billing details. 错误码 insufficient_quota&#xff0c;HTTP 状态码 429。…...

如何解决网页图片格式转换难题?这款Chrome扩展让效率提升3倍

如何解决网页图片格式转换难题&#xff1f;这款Chrome扩展让效率提升3倍 【免费下载链接】Save-Image-as-Type Save Image as Type is an chrome extension which add Save as PNG / JPG / WebP to the context menu of image. 项目地址: https://gitcode.com/gh_mirrors/sa/…...