Mybatis源码篇:Mybatis初始化过程分析

news2024/11/15 4:56:10

文章目录

    • 1. Mybatis初始化过程简述
    • 2. Mybatis初始化源码分析
      • 2.1 Mybatis初始化时序图
      • 2.2 源码分析
        • 2.2.1 SqlSessionFactoryUtil测试类代码
        • 2.2.2 SqlSessionFactoryBuilder源码
        • 2.2.3 XMLConfigBuilder源码
        • 2.2.4 SqlSessionFactory相关属性
        • 2.2.5 SqlSession相关属性
    • 3. 总结
    • 4. 使用到的设计模式
    • 5. 参考

1. Mybatis初始化过程简述

  1. 通过Resources这个类获取一个输入流,加载mybatis的核心配置文件
  2. 然后创建SqlSessionFactoryBuilder实例通过build()方法去读取这个输入流,得到一个工厂对象
    第一步:底层会创建一个装载配置文件的类XMLConfigBuild
    第二步:通过这个类的对象的parse()方法去真正获取一个装载了所有配置文件的类对象configuration,该对象封装了我们在mybatis.xml中配置的所有信息.
    第三步:就这样,一个包含了所有配置信息的工厂对象sqlSessionFactory诞生了
  3. 通过工厂建立sqlSession对象,每一个线程都独立拥有自己的sqlSession,该对象包含了执行sql的executor执行器,执行器包含了缓存信息等重要信息.
  4. 通过sqlSession获取一个mapper的代理实现类,执行特定接口里的方法
  5. 执行完成后,有异常则回滚,没有则提交

2. Mybatis初始化源码分析

通过自己编写的测试工具类SqlSessionFactoryUtil来对Mybatis初始化过程进行直观展示

2.1 Mybatis初始化时序图

在这里插入图片描述

2.2 源码分析

2.2.1 SqlSessionFactoryUtil测试类代码

单例模式,调用SqlSessionFactoryBuilder的build()方法,构建SqlSessionFactory,提供了获取SqlSession的方法。

public class SqlSessionFactoryUtil {
    //SQLSessionFactory对象
    private static SqlSessionFactory sqlSessionFactory = null;
    //类线程锁
    private static final Class CLASS_LOCK = SqlSessionFactoryUtil.class;

    private SqlSessionFactoryUtil() {}

    /**
     * 构建SqlSessionFactory
     */
    public static SqlSessionFactory init() {
        String resource = "mybatis-config.xml";
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream(resource);
        } catch (IOException ex) {
            Logger.getLogger(SqlSessionFactoryUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
        synchronized(CLASS_LOCK) {
            if(sqlSessionFactory == null) {
            //调用SqlSessionFactoryBuilder的build()方法
                sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            }
        }
        return sqlSessionFactory;
    }

    /**
     * 打开SqlSession
     */
    public static SqlSession openSqlSession() {
        if (sqlSessionFactory == null) {
            init();
        }
        return sqlSessionFactory.openSession();
    }
}

2.2.2 SqlSessionFactoryBuilder源码

流程:通过XMLConfigBuilder读取配置到Configuration类,再利用读取出来的config构建DefaultSqlSessionFactory

public class SqlSessionFactoryBuilder {

  public SqlSessionFactory build(Reader reader) {
    return build(reader, null, null);
  }

  public SqlSessionFactory build(Reader reader, String environment) {
    return build(reader, environment, null);
  }

  public SqlSessionFactory build(Reader reader, Properties properties) {
    return build(reader, null, properties);
  }

  public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {
      XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties);
      return build(parser.parse());
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
      ErrorContext.instance().reset();
      try {
        reader.close();
      } catch (IOException e) {
        // Intentionally ignore. Prefer previous error.
      }
    }
  }
  //使用的是这个方法构建SqlSessionFactory
  public SqlSessionFactory build(InputStream inputStream) {
    return build(inputStream, null, null);
  }

  public SqlSessionFactory build(InputStream inputStream, String environment) {
    return build(inputStream, environment, null);
  }

  public SqlSessionFactory build(InputStream inputStream, Properties properties) {
    return build(inputStream, null, properties);
  }
  //构建build
  public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {
      XMLConfigBuilder parser = new XMLConfigBuilder(inputStream, environment, properties); //XMLConfigBuilder解析mybatis-config.xml配置
      return build(parser.parse());
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
      ErrorContext.instance().reset();
      try {
        inputStream.close();
      } catch (IOException e) {
        // Intentionally ignore. Prefer previous error.
      }
    }
  }

  public SqlSessionFactory build(Configuration config) {
    return new DefaultSqlSessionFactory(config);
  }

}

2.2.3 XMLConfigBuilder源码

流程:读取并保存mybatis-config配置文件中大部分节点属性

public class XMLConfigBuilder extends BaseBuilder {

  private boolean parsed;
  private final XPathParser parser;
  private String environment;
  private final ReflectorFactory localReflectorFactory = new DefaultReflectorFactory();

  public XMLConfigBuilder(Reader reader) {
    this(reader, null, null);
  }

  public XMLConfigBuilder(Reader reader, String environment) {
    this(reader, environment, null);
  }

  public XMLConfigBuilder(Reader reader, String environment, Properties props) {
    this(new XPathParser(reader, true, props, new XMLMapperEntityResolver()), environment, props);
  }

  public XMLConfigBuilder(InputStream inputStream) {
    this(inputStream, null, null);
  }

  public XMLConfigBuilder(InputStream inputStream, String environment) {
    this(inputStream, environment, null);
  }

  public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
    this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
  }

  private XMLConfigBuilder(XPathParser parser, String environment, Properties props) {
    super(new Configuration());
    ErrorContext.instance().resource("SQL Mapper Configuration");
    this.configuration.setVariables(props);
    this.parsed = false;
    this.environment = environment;
    this.parser = parser;
  }

  public Configuration parse() {
    if (parsed) {
      throw new BuilderException("Each XMLConfigBuilder can only be used once.");
    }
    parsed = true;
    parseConfiguration(parser.evalNode("/configuration"));
    return configuration;
  }

  private void parseConfiguration(XNode root) {
    try {
      //issue #117 read properties first
      propertiesElement(root.evalNode("properties"));
      Properties settings = settingsAsProperties(root.evalNode("settings"));
      loadCustomVfs(settings);
      loadCustomLogImpl(settings);
      typeAliasesElement(root.evalNode("typeAliases"));
      pluginElement(root.evalNode("plugins"));
      objectFactoryElement(root.evalNode("objectFactory"));
      objectWrapperFactoryElement(root.evalNode("objectWrapperFactory"));
      reflectorFactoryElement(root.evalNode("reflectorFactory"));
      settingsElement(settings);
      // read it after objectFactory and objectWrapperFactory issue #631
      environmentsElement(root.evalNode("environments"));
      databaseIdProviderElement(root.evalNode("databaseIdProvider"));
      typeHandlerElement(root.evalNode("typeHandlers"));
      mapperElement(root.evalNode("mappers"));
    } catch (Exception e) {
      throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e);
    }
  }

  private Properties settingsAsProperties(XNode context) {
    if (context == null) {
      return new Properties();
    }
    Properties props = context.getChildrenAsProperties();
    // Check that all settings are known to the configuration class
    MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
    for (Object key : props.keySet()) {
      if (!metaConfig.hasSetter(String.valueOf(key))) {
        throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
      }
    }
    return props;
  }

  private void loadCustomVfs(Properties props) throws ClassNotFoundException {
    String value = props.getProperty("vfsImpl");
    if (value != null) {
      String[] clazzes = value.split(",");
      for (String clazz : clazzes) {
        if (!clazz.isEmpty()) {
          @SuppressWarnings("unchecked")
          Class<? extends VFS> vfsImpl = (Class<? extends VFS>)Resources.classForName(clazz);
          configuration.setVfsImpl(vfsImpl);
        }
      }
    }
  }

  private void loadCustomLogImpl(Properties props) {
    Class<? extends Log> logImpl = resolveClass(props.getProperty("logImpl"));
    configuration.setLogImpl(logImpl);
  }

  private void typeAliasesElement(XNode parent) {
    if (parent != null) {
      for (XNode child : parent.getChildren()) {
        if ("package".equals(child.getName())) {
          String typeAliasPackage = child.getStringAttribute("name");
          configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
        } else {
          String alias = child.getStringAttribute("alias");
          String type = child.getStringAttribute("type");
          try {
            Class<?> clazz = Resources.classForName(type);
            if (alias == null) {
              typeAliasRegistry.registerAlias(clazz);
            } else {
              typeAliasRegistry.registerAlias(alias, clazz);
            }
          } catch (ClassNotFoundException e) {
            throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
          }
        }
      }
    }
  }

  private void pluginElement(XNode parent) throws Exception {
    if (parent != null) {
      for (XNode child : parent.getChildren()) {
        String interceptor = child.getStringAttribute("interceptor");
        Properties properties = child.getChildrenAsProperties();
        Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
        interceptorInstance.setProperties(properties);
        configuration.addInterceptor(interceptorInstance);
      }
    }
  }

  private void objectFactoryElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type");
      Properties properties = context.getChildrenAsProperties();
      ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance();
      factory.setProperties(properties);
      configuration.setObjectFactory(factory);
    }
  }

  private void objectWrapperFactoryElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type");
      ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance();
      configuration.setObjectWrapperFactory(factory);
    }
  }

  private void reflectorFactoryElement(XNode context) throws Exception {
    if (context != null) {
       String type = context.getStringAttribute("type");
       ReflectorFactory factory = (ReflectorFactory) resolveClass(type).newInstance();
       configuration.setReflectorFactory(factory);
    }
  }

  private void propertiesElement(XNode context) throws Exception {
    if (context != null) {
      Properties defaults = context.getChildrenAsProperties();
      String resource = context.getStringAttribute("resource");
      String url = context.getStringAttribute("url");
      if (resource != null && url != null) {
        throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
      }
      if (resource != null) {
        defaults.putAll(Resources.getResourceAsProperties(resource));
      } else if (url != null) {
        defaults.putAll(Resources.getUrlAsProperties(url));
      }
      Properties vars = configuration.getVariables();
      if (vars != null) {
        defaults.putAll(vars);
      }
      parser.setVariables(defaults);
      configuration.setVariables(defaults);
    }
  }

  private void settingsElement(Properties props) {
    configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
    configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
    configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
    configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
    configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
    configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false));
    configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
    configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
    configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
    configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
    configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
    configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
    configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
    configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
    configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
    configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
    configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
    configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
    configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
    configuration.setDefaultEnumTypeHandler(resolveClass(props.getProperty("defaultEnumTypeHandler")));
    configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
    configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
    configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false));
    configuration.setLogPrefix(props.getProperty("logPrefix"));
    configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
  }

  private void environmentsElement(XNode context) throws Exception {
    if (context != null) {
      if (environment == null) {
        environment = context.getStringAttribute("default");
      }
      for (XNode child : context.getChildren()) {
        String id = child.getStringAttribute("id");
        if (isSpecifiedEnvironment(id)) {
          TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
          DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
          DataSource dataSource = dsFactory.getDataSource();
          Environment.Builder environmentBuilder = new Environment.Builder(id)
              .transactionFactory(txFactory)
              .dataSource(dataSource);
          configuration.setEnvironment(environmentBuilder.build());
        }
      }
    }
  }

  private void databaseIdProviderElement(XNode context) throws Exception {
    DatabaseIdProvider databaseIdProvider = null;
    if (context != null) {
      String type = context.getStringAttribute("type");
      // awful patch to keep backward compatibility
      if ("VENDOR".equals(type)) {
          type = "DB_VENDOR";
      }
      Properties properties = context.getChildrenAsProperties();
      databaseIdProvider = (DatabaseIdProvider) resolveClass(type).newInstance();
      databaseIdProvider.setProperties(properties);
    }
    Environment environment = configuration.getEnvironment();
    if (environment != null && databaseIdProvider != null) {
      String databaseId = databaseIdProvider.getDatabaseId(environment.getDataSource());
      configuration.setDatabaseId(databaseId);
    }
  }

  private TransactionFactory transactionManagerElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type");
      Properties props = context.getChildrenAsProperties();
      TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
      factory.setProperties(props);
      return factory;
    }
    throw new BuilderException("Environment declaration requires a TransactionFactory.");
  }

  private DataSourceFactory dataSourceElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type");
      Properties props = context.getChildrenAsProperties();
      DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
      factory.setProperties(props);
      return factory;
    }
    throw new BuilderException("Environment declaration requires a DataSourceFactory.");
  }

  private void typeHandlerElement(XNode parent) {
    if (parent != null) {
      for (XNode child : parent.getChildren()) {
        if ("package".equals(child.getName())) {
          String typeHandlerPackage = child.getStringAttribute("name");
          typeHandlerRegistry.register(typeHandlerPackage);
        } else {
          String javaTypeName = child.getStringAttribute("javaType");
          String jdbcTypeName = child.getStringAttribute("jdbcType");
          String handlerTypeName = child.getStringAttribute("handler");
          Class<?> javaTypeClass = resolveClass(javaTypeName);
          JdbcType jdbcType = resolveJdbcType(jdbcTypeName);
          Class<?> typeHandlerClass = resolveClass(handlerTypeName);
          if (javaTypeClass != null) {
            if (jdbcType == null) {
              typeHandlerRegistry.register(javaTypeClass, typeHandlerClass);
            } else {
              typeHandlerRegistry.register(javaTypeClass, jdbcType, typeHandlerClass);
            }
          } else {
            typeHandlerRegistry.register(typeHandlerClass);
          }
        }
      }
    }
  }

  private void mapperElement(XNode parent) throws Exception {
    if (parent != null) {
      for (XNode child : parent.getChildren()) {
        if ("package".equals(child.getName())) {
          String mapperPackage = child.getStringAttribute("name");
          configuration.addMappers(mapperPackage);
        } else {
          String resource = child.getStringAttribute("resource");
          String url = child.getStringAttribute("url");
          String mapperClass = child.getStringAttribute("class");
          if (resource != null && url == null && mapperClass == null) {
            ErrorContext.instance().resource(resource);
            InputStream inputStream = Resources.getResourceAsStream(resource);
            XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
            mapperParser.parse();
          } else if (resource == null && url != null && mapperClass == null) {
            ErrorContext.instance().resource(url);
            InputStream inputStream = Resources.getUrlAsStream(url);
            XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, url, configuration.getSqlFragments());
            mapperParser.parse();
          } else if (resource == null && url == null && mapperClass != null) {
            Class<?> mapperInterface = Resources.classForName(mapperClass);
            configuration.addMapper(mapperInterface);
          } else {
            throw new BuilderException("A mapper element may only specify a url, resource or class, but not more than one.");
          }
        }
      }
    }
  }

  private boolean isSpecifiedEnvironment(String id) {
    if (environment == null) {
      throw new BuilderException("No environment specified.");
    } else if (id == null) {
      throw new BuilderException("Environment requires an id attribute.");
    } else if (environment.equals(id)) {
      return true;
    }
    return false;
  }

}

2.2.4 SqlSessionFactory相关属性

在这里插入图片描述

2.2.5 SqlSession相关属性

在这里插入图片描述

3. 总结

通过Resources读取Mybatis核心配置信息,在SqlSessionFactoryBuilder类中,用XMLConfigBuilder解析配置信息,生成Configuration类,最后返回工厂类SqlSessionFactory,通过工厂类建立SqlSession,在session中完成对数据的增删改查和事务管理。

4. 使用到的设计模式

建造者模式:SqlSessionFactoryBuilder、XMLConfigBuilder
工厂模式:SqlSessionFactory

5. 参考

https://blog.csdn.net/qq_40598321/article/details/108077267
https://www.cnblogs.com/magic-sea/p/11196778.html

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

2:PCIe Header配置空间

目录 1.概述 2.Header Type0 2.1 HeaderType字段 2.2 Class寄存器 2.3 Cache Line Size 寄存器 2.4 Subsystem ID 和 Subsystem Vendor ID 寄存器 2.5 Capabilities Pointer 寄存器 2.6 Interrupt Line 寄存器 2.7 Interrupt Pin 寄存器 2.8 Base Address Registe…

el-select如何不显示value,显示value对应的label值

文章目录 select 显示如下发生错误的原因 select 显示如下 el-select在编辑调用的时候一直显示的不是label值&#xff0c;而是本身的value值。尝试了很多种方法&#xff0c;都没有解决。 正常的形式 错误的形式 发生错误的原因 显示不正常&#xff0c;多数是由于得到的数据…

人工智能期末复习(背题家的落幕)

文章目录 一、前言二、选择题&#xff08;10 X 2&#xff09;1、补充2、第一梯队⭐⭐⭐3、第二梯队⭐⭐4、第三梯队⭐ 三、判断题&#xff08;10 X 1&#xff09;1、错误的2、正确的 四、程序填空题&#xff08;10 X 3&#xff09;1、tensorflow搭建模型2、keras模型编译3、Pyt…

AI智慧安监视频融合平台EasyCVR播放HLS流出现报错404是什么原因?

EasyCVR平台支持多协议与多类型设备接入&#xff0c;具体包括国标GB28181、RTMP、RTSP/Onvif、海康Ehome、海康SDK、大华SDK、宇视SDK等&#xff0c;能对外分发RTMP、RTSP、HTTP-FLV、WS-FLV、HLS、WebRTC等。平台既具备传统安防视频监控的能力&#xff0c;也能接入AI智能分析的…

【强化学习】什么是“强化学习”

作者主页&#xff1a;爱笑的男孩。的博客_CSDN博客-深度学习,活动,python领域博主爱笑的男孩。擅长深度学习,活动,python,等方面的知识,爱笑的男孩。关注算法,python,计算机视觉,图像处理,深度学习,pytorch,神经网络,opencv领域.https://blog.csdn.net/Code_and516?typeblog个…

MySQL的存储过程

MySQL 一、存储过程的概念存储过程的优点 二、创建简单的存储过程三、存储过程的参数IN 输入参数OUT 输出参数INOUT 输入输出参数 四、删除存储过程五、存储过程的控制语句条件语句循环语句 一、存储过程的概念 存储过程是一组为了完成特定功能的SQL语句。 存储过程再使用过程…

安装rabbitmqctl问题

RabbitMQ Server 311.18 Setup bat start xited with code 1. 主要对应得erlang版本不对&#xff08;注意 安装过程中一定要对应指定版本&#xff0c;尽量装低一版本&#xff0c;并且erlang选择中间版本&#xff09; RabbitMQ Erlang Version Requirements — RabbitMQ

adb shell后,getevent退出方法

adb shell后&#xff0c;getevent退出方法 输入 exit 然后回车退出

使用 Debian、Docker 和 Nginx 部署 Web 应用

前言 本文将介绍基于 Debian 的系统上使用 Docker 和 Nginx 进行 Web 应用部署的过程。着重介绍了 Debian、Docker 和 Nginx 的安装和配置。 第 1 步&#xff1a;更新和升级 Debian 系统 通过 SSH 连接到服务器。更新软件包列表&#xff1a;sudo apt update升级已安装的软件…

pointNet训练预测自己的数据集Charles版本(二)

之前博客介绍了如何跑通charles版本的pointNet&#xff0c;这篇介绍下如何来训练和预测自己的数据集&#xff0c;介绍如何在自己的数据集上做点云语义分割&#xff0c;此篇的环境配置和博客中保持一致。点云分类较简单&#xff0c;方法差不多&#xff0c;这边就不特地说明了。 …

RFID智能物料仓库管理系统

文章目录 设计任务及要求一、需求分析1.1 硬件图1.1.1 GEC6818开发板模块介绍1.1.2 低频RFID模块 1.2 软件图 二、概要设计2.1 功能流程图2.1.1 模块层次关系2.1.2 防碰撞2.1.3 步骤流程图 三、详细设计3.1 摄像头模块代码3.2 串口初始化模块代码分析3.3 报警模块代码分析3.4 光…

java项目之房屋租赁系统ssm源码

风定落花生&#xff0c;歌声逐流水&#xff0c;大家好我是风歌&#xff0c;混迹在java圈的辛苦码农。今天要和大家聊的是一款基于ssm的房屋租赁系统。项目源码以及部署相关请联系风歌&#xff0c;文末附上联系信息 。 &#x1f495;&#x1f495;作者&#xff1a;风歌&#xff…

SDH接口能够用DAT3作为插入侦测引脚

SDH&#xff08;Secure Digital Host&#xff09;接口需要 9 个引脚来实现其功能&#xff0c;这些引脚包括&#xff1a; VDD&#xff1a;电源引脚&#xff0c;通常连接到3.3V的电源。 VSS&#xff1a;地引脚&#xff0c;通常连接到系统的地线。 DAT0&#xff1a;数据线0&…

【Linux】在simplescreenrecorder中录制的视频,打开的时候是黑屏,显示不了任何画面

一、问题背景 在simplescreenrecorder中录制的视频&#xff0c;打开的时候是黑屏&#xff0c;显示不了任何画面 当时我以为是软件本身设置有问题&#xff0c;于是乎就到处调。网上有些回答说可能是显卡驱动问题&#xff0c;这个驱动我可不敢随便重装啊&#xff0c;太花时间了…

PSP - AlphaFold2 根据 Species 进行 MSA Pairing 的源码解析

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://blog.csdn.net/caroline_wendy/article/details/131399818 AlphaFold2 Multimer 能够预测多肽链之间相互作用的方法&#xff0c;使用 MSA Pairing 的技术。MSA Pairing 是指通过比较 MS…

C# 实现全局鼠标钩子操作以及发送键盘事件

全局钩子定义 using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks;namespace WindowsFormsApp1 {public static class GlobalMousePositi…

【云原生 | 55】Docker三剑客之Docker Swarm简介和安装

&#x1f341;博主简介&#xff1a; &#x1f3c5;云计算领域优质创作者 &#x1f3c5;2022年CSDN新星计划python赛道第一名 &#x1f3c5;2022年CSDN原力计划优质作者 &#x1f3c5;阿里云ACE认证高级工程师 &#x1f3c5;阿里云开发者社区专…

chatgpt赋能python:Python如何获取激光雷达数据

Python如何获取激光雷达数据 激光雷达数据在机器学习和自动驾驶领域中扮演着重要的角色。Python作为一种功能强大而又易于学习的编程语言&#xff0c;在获取激光雷达数据方面也表现出极高的效率和灵活性。下面我们将介绍如何使用Python获取激光雷达数据。 什么是激光雷达数据…

vue-li问题记录

Starting development server... ERROR ValidationError: webpack Dev Server Invalid Options options should NOT have additional properties options should NOT have additional properties 大概是package.json或者是vue.config.js文件出现类问题&#xff0c;我把这两…

chatgpt赋能python:Python计算BMI-一篇完整的指南

Python 计算BMI - 一篇完整的指南 我们都知道&#xff0c;BMI是身体质量指数的简称&#xff0c;它是以身高和体重计算的一个数值&#xff0c;用来评估一个人的身体状况。在本文中&#xff0c;我们将介绍如何使用Python计算BMI&#xff0c;并提供一些关于BMI的背景知识。 什么…