Springboot整合Mybaits启动过程

Springboot整合Mybaits启动过程

  • 1.前言
  • 2.MybatisAutoConfiguration
  • 3.SqlSessionFactoryBean
    • 3.1 XMLConfigBuilder.parse()
      • 3.1.1 XMLMapperBuilder.parse()
        • 3.1.1.1 XMLStatementBuilder.parse()
  • 4.SqlSession
    • 4.1 Executor

1.前言

直接加载mybatis配置文件,然后创建SqlSessionFactory ,获取SqlSession来进行数据库操作

//加载配置文件
InputStream resourceAsStream = Resources.getResourceAsStream("ybatis-config.xml");
//创建sqlSessionFactory
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
//通过sqlsessionfactory得到sqlsession(sqlsession是操作数据库的关键对象)
SqlSession sqlSession = sqlSessionFactory.openSession();
}

而当Springboot整合Mybatis 时,这个 SqlSessionFactory 对象应该交由 Spring 容器来管理。
Spirngboot自动装配:Spirngboot自动装配

2.MybatisAutoConfiguration

我们知道springboot开箱即用,就是因为它能够自动装配,而自动装配的原理,就时会从META-INFO下的spring.factories文件中获取要自动装配的类。
在这里插入图片描述
进入MybatisAutoConfiguration类中

@org.springframework.context.annotation.Configuration
@ConditionalOnClass({ SqlSessionFactory.class, SqlSessionFactoryBean.class })
@ConditionalOnBean(DataSource.class)
@EnableConfigurationProperties(MybatisProperties.class)
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class MybatisAutoConfiguration {......@Bean@ConditionalOnMissingBeanpublic SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {// 创建SqlSessionFactoryBean对象SqlSessionFactoryBean factory = new SqlSessionFactoryBean();// 设置数据源factory.setDataSource(dataSource);// 设置VFS为SpringBootVFSfactory.setVfs(SpringBootVFS.class);if (StringUtils.hasText(this.properties.getConfigLocation())) {// 如果配置了配置文件路径,则设置ConfigLocationfactory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));}Configuration configuration = this.properties.getConfiguration();if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {// 如果未配置配置文件路径且没有指定配置对象,则创建一个新的Configuration对象configuration = new Configuration();}if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {// 如果存在配置对象且有配置自定义器,则依次调用自定义器的customize()方法对配置对象进行自定义for (ConfigurationCustomizer customizer : this.configurationCustomizers) {customizer.customize(configuration);}}// 设置配置对象factory.setConfiguration(configuration);if (this.properties.getConfigurationProperties() != null) {// 如果配置了额外的配置属性,则设置到SqlSessionFactoryBean中factory.setConfigurationProperties(this.properties.getConfigurationProperties());}if (!ObjectUtils.isEmpty(this.interceptors)) {// 如果存在拦截器,则设置到SqlSessionFactoryBean中factory.setPlugins(this.interceptors);}if (this.databaseIdProvider != null) {// 如果存在数据库ID提供者,则设置到SqlSessionFactoryBean中factory.setDatabaseIdProvider(this.databaseIdProvider);}if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {// 如果配置了类型别名包路径,则设置到SqlSessionFactoryBean中factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());}if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {// 如果配置了类型处理器包路径,则设置到SqlSessionFactoryBean中factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());}if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {// 如果存在Mapper文件路径,则解析并设置到SqlSessionFactoryBean中factory.setMapperLocations(this.properties.resolveMapperLocations());}// 返回创建的SqlSessionFactory对象return factory.getObject();}......
}
@org.springframework.context.annotation.Configuration: 
这个注解表示这个类是一个配置类,Spring会在启动时加载并解析它。@ConditionalOnClass({ SqlSessionFactory.class, SqlSessionFactoryBean.class }): 
这个注解表示只有在类路径中存在SqlSessionFactorySqlSessionFactoryBean类时才会进行自动配置。@ConditionalOnBean(DataSource.class): 
这个注解表示只有当容器中已经存在DataSource类型的Bean时才会进行自动配置。@EnableConfigurationProperties(MybatisProperties.class): 
这个注解启用了MybatisProperties类的配置。它会将该类的属性值绑定到MybatisAutoConfiguration类中。@AutoConfigureAfter(DataSourceAutoConfiguration.class): 
这个注解表示该自动配置类需要在DataSourceAutoConfiguration类之后进行自动配置。

从上面代码可以知道,SqlSessionFactory Bean在这里被创建和配置,交给spring容器管理,SqlSessionFactory又是怎么创建的呢?我们来看SqlSessionFactoryBean

3.SqlSessionFactoryBean

我们可以看到SqlSessionFactoryBean实现了InitializingBean接口,覆写了afterPropertiesSet方法

public class SqlSessionFactoryBean implements FactoryBean<SqlSessionFactory>, InitializingBean, ApplicationListener<ApplicationEvent> {......@Overridepublic void afterPropertiesSet() throws Exception {notNull(dataSource, "Property 'dataSource' is required");notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required");state((configuration == null && configLocation == null) || !(configuration != null && configLocation != null),"Property 'configuration' and 'configLocation' can not specified with together");// 这里使用了建造者模式进行SqlSessionFactory的创建this.sqlSessionFactory = buildSqlSessionFactory();}protected SqlSessionFactory buildSqlSessionFactory() throws IOException {Configuration configuration;XMLConfigBuilder xmlConfigBuilder = null;if (this.configuration != null) {configuration = this.configuration;if (configuration.getVariables() == null) {configuration.setVariables(this.configurationProperties);} else if (this.configurationProperties != null) {configuration.getVariables().putAll(this.configurationProperties);}} else if (this.configLocation != null) {// 构建XmlConfigBuilder,准备解析XML文件的基础环境xmlConfigBuilder = new XMLConfigBuilder(this.configLocation.getInputStream(), null, this.configurationProperties);configuration = xmlConfigBuilder.getConfiguration();} else {if (LOGGER.isDebugEnabled()) {LOGGER.debug("Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration");}configuration = new Configuration();if (this.configurationProperties != null) {configuration.setVariables(this.configurationProperties);}}if (this.objectFactory != null) {configuration.setObjectFactory(this.objectFactory);}if (this.objectWrapperFactory != null) {configuration.setObjectWrapperFactory(this.objectWrapperFactory);}if (this.vfs != null) {configuration.setVfsImpl(this.vfs);}if (hasLength(this.typeAliasesPackage)) {String[] typeAliasPackageArray = tokenizeToStringArray(this.typeAliasesPackage,ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);for (String packageToScan : typeAliasPackageArray) {configuration.getTypeAliasRegistry().registerAliases(packageToScan,typeAliasesSuperType == null ? Object.class : typeAliasesSuperType);if (LOGGER.isDebugEnabled()) {LOGGER.debug("Scanned package: '" + packageToScan + "' for aliases");}}}if (!isEmpty(this.typeAliases)) {for (Class<?> typeAlias : this.typeAliases) {configuration.getTypeAliasRegistry().registerAlias(typeAlias);if (LOGGER.isDebugEnabled()) {LOGGER.debug("Registered type alias: '" + typeAlias + "'");}}}if (!isEmpty(this.plugins)) {for (Interceptor plugin : this.plugins) {configuration.addInterceptor(plugin);if (LOGGER.isDebugEnabled()) {LOGGER.debug("Registered plugin: '" + plugin + "'");}}}if (hasLength(this.typeHandlersPackage)) {String[] typeHandlersPackageArray = tokenizeToStringArray(this.typeHandlersPackage,ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);for (String packageToScan : typeHandlersPackageArray) {configuration.getTypeHandlerRegistry().register(packageToScan);if (LOGGER.isDebugEnabled()) {LOGGER.debug("Scanned package: '" + packageToScan + "' for type handlers");}}}if (!isEmpty(this.typeHandlers)) {for (TypeHandler<?> typeHandler : this.typeHandlers) {configuration.getTypeHandlerRegistry().register(typeHandler);if (LOGGER.isDebugEnabled()) {LOGGER.debug("Registered type handler: '" + typeHandler + "'");}}}if (this.databaseIdProvider != null) {//fix #64 set databaseId before parse mapper xmlstry {configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource));} catch (SQLException e) {throw new NestedIOException("Failed getting a databaseId", e);}}if (this.cache != null) {configuration.addCache(this.cache);}if (xmlConfigBuilder != null) {try {// xml文件解析xmlConfigBuilder.parse();if (LOGGER.isDebugEnabled()) {LOGGER.debug("Parsed configuration file: '" + this.configLocation + "'");}} catch (Exception ex) {throw new NestedIOException("Failed to parse config resource: " + this.configLocation, ex);} finally {ErrorContext.instance().reset();}}if (this.transactionFactory == null) {this.transactionFactory = new SpringManagedTransactionFactory();}configuration.setEnvironment(new Environment(this.environment, this.transactionFactory, this.dataSource));if (!isEmpty(this.mapperLocations)) {for (Resource mapperLocation : this.mapperLocations) {if (mapperLocation == null) {continue;}try {XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(),configuration, mapperLocation.toString(), configuration.getSqlFragments());xmlMapperBuilder.parse();} catch (Exception e) {throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);} finally {ErrorContext.instance().reset();}if (LOGGER.isDebugEnabled()) {LOGGER.debug("Parsed mapper file: '" + mapperLocation + "'");}}} else {if (LOGGER.isDebugEnabled()) {LOGGER.debug("Property 'mapperLocations' was not specified or no matching resources found");}}// 构建SqlSessionFactory,返回的是DefaultSqlSessionFactoryreturn this.sqlSessionFactoryBuilder.build(configuration);}......
}

从上面代码可以知道经过一系列操作最后通过sqlSessionFactoryBuilder创建了SqlSessionFactory。下面来看一下XML文件的解析

3.1 XMLConfigBuilder.parse()

public Configuration parse() {if (parsed) {throw new BuilderException("Each XMLConfigBuilder can only be used once.");}parsed = true;// xml配置文件转化成ConfigurationparseConfiguration(parser.evalNode("/configuration"));return configuration;}
  private void parseConfiguration(XNode root) {try {// 该方法中,将<configuration>下的所有节点分开处理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);environmentsElement(root.evalNode("environments"));databaseIdProviderElement(root.evalNode("databaseIdProvider"));typeHandlerElement(root.evalNode("typeHandlers"));// 解析映射文件,并将相关信息保存到Configuration对象中mapperElement(root.evalNode("mappers"));} catch (Exception e) {throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e);}}
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);// 创建XMLMapperBuilderXMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());// mapper文件解析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.");}}}}}

3.1.1 XMLMapperBuilder.parse()

public void parse() {if (!configuration.isResourceLoaded(resource)) {configurationElement(parser.evalNode("/mapper"));configuration.addLoadedResource(resource);bindMapperForNamespace();}parsePendingResultMaps();parsePendingCacheRefs();parsePendingStatements();}private void configurationElement(XNode context) {try {String namespace = context.getStringAttribute("namespace");if (namespace == null || namespace.equals("")) {throw new BuilderException("Mapper's namespace cannot be empty");}builderAssistant.setCurrentNamespace(namespace);cacheRefElement(context.evalNode("cache-ref"));cacheElement(context.evalNode("cache"));parameterMapElement(context.evalNodes("/mapper/parameterMap"));resultMapElements(context.evalNodes("/mapper/resultMap"));sqlElement(context.evalNodes("/mapper/sql"));buildStatementFromContext(context.evalNodes("select|insert|update|delete"));} catch (Exception e) {throw new BuilderException("Error parsing Mapper XML. The XML location is '" + resource + "'. Cause: " + e, e);}}
private void buildStatementFromContext(List<XNode> list) {if (configuration.getDatabaseId() != null) {buildStatementFromContext(list, configuration.getDatabaseId());}buildStatementFromContext(list, null);}private void buildStatementFromContext(List<XNode> list, String requiredDatabaseId) {for (XNode context : list) {final XMLStatementBuilder statementParser = new XMLStatementBuilder(configuration, builderAssistant, context, requiredDatabaseId);try {statementParser.parseStatementNode();} catch (IncompleteElementException e) {configuration.addIncompleteStatement(statementParser);}}}
3.1.1.1 XMLStatementBuilder.parse()
public void parseStatementNode() {String id = context.getStringAttribute("id");String databaseId = context.getStringAttribute("databaseId");if (!databaseIdMatchesCurrent(id, databaseId, this.requiredDatabaseId)) {return;}String nodeName = context.getNode().getNodeName();SqlCommandType sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase(Locale.ENGLISH));boolean isSelect = sqlCommandType == SqlCommandType.SELECT;boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);boolean useCache = context.getBooleanAttribute("useCache", isSelect);boolean resultOrdered = context.getBooleanAttribute("resultOrdered", false);XMLIncludeTransformer includeParser = new XMLIncludeTransformer(configuration, builderAssistant);includeParser.applyIncludes(context.getNode());String parameterType = context.getStringAttribute("parameterType");Class<?> parameterTypeClass = resolveClass(parameterType);String lang = context.getStringAttribute("lang");LanguageDriver langDriver = getLanguageDriver(lang);// Parse selectKey after includes and remove them.processSelectKeyNodes(id, parameterTypeClass, langDriver);// Parse the SQL (pre: <selectKey> and <include> were parsed and removed)KeyGenerator keyGenerator;String keyStatementId = id + SelectKeyGenerator.SELECT_KEY_SUFFIX;keyStatementId = builderAssistant.applyCurrentNamespace(keyStatementId, true);if (configuration.hasKeyGenerator(keyStatementId)) {keyGenerator = configuration.getKeyGenerator(keyStatementId);} else {keyGenerator = context.getBooleanAttribute("useGeneratedKeys",configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))? Jdbc3KeyGenerator.INSTANCE : NoKeyGenerator.INSTANCE;}SqlSource sqlSource = langDriver.createSqlSource(configuration, context, parameterTypeClass);StatementType statementType = StatementType.valueOf(context.getStringAttribute("statementType", StatementType.PREPARED.toString()));Integer fetchSize = context.getIntAttribute("fetchSize");Integer timeout = context.getIntAttribute("timeout");String parameterMap = context.getStringAttribute("parameterMap");String resultType = context.getStringAttribute("resultType");Class<?> resultTypeClass = resolveClass(resultType);String resultMap = context.getStringAttribute("resultMap");String resultSetType = context.getStringAttribute("resultSetType");ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);String keyProperty = context.getStringAttribute("keyProperty");String keyColumn = context.getStringAttribute("keyColumn");String resultSets = context.getStringAttribute("resultSets");builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,resultSetTypeEnum, flushCache, useCache, resultOrdered,keyGenerator, keyProperty, keyColumn, databaseId, langDriver, resultSets);}

到这里我们可以看到整个解析过程是对xml文件使用相应的xmlBuilder的parse()方法层层解析

4.SqlSession

在这里插入图片描述
构建好SqlSessionFactory后,就能获取到SqlSession。我们知道通过sqlSessionFactoryBuilder创建了SqlSessionFactory,并且返回的是实现了SqlSessionFactory的DefaultSqlSessionFactory,通过openSession()方法则可以获取SqlSession

public interface SqlSessionFactory {SqlSession openSession();SqlSession openSession(boolean autoCommit);SqlSession openSession(Connection connection);SqlSession openSession(TransactionIsolationLevel level);SqlSession openSession(ExecutorType execType);SqlSession openSession(ExecutorType execType, boolean autoCommit);SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level);SqlSession openSession(ExecutorType execType, Connection connection);Configuration getConfiguration();}
@Overridepublic SqlSession openSession() {return openSessionFromDataSource(configuration.getDefaultExecutorType(), null, false);}private SqlSession openSessionFromDataSource(ExecutorType execType, TransactionIsolationLevel level, boolean autoCommit) {Transaction tx = null;try {final Environment environment = configuration.getEnvironment();final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);tx = transactionFactory.newTransaction(environment.getDataSource(), level, autoCommit);// 创建执行器final Executor executor = configuration.newExecutor(tx, execType);// 这里返回的是实现了SqlSeesion的DefaultSqlSessionreturn new DefaultSqlSession(configuration, executor, autoCommit);} catch (Exception e) {closeTransaction(tx); // may have fetched a connection so lets call close()throw ExceptionFactory.wrapException("Error opening session.  Cause: " + e, e);} finally {ErrorContext.instance().reset();}}

在这里插入图片描述

public DefaultSqlSession(Configuration configuration, Executor executor, boolean autoCommit) {this.configuration = configuration;this.executor = executor;this.dirty = false;this.autoCommit = autoCommit;}

在DefaultSqlSession我们可以看到很多我们熟悉的对数据库操作的方法
在这里插入图片描述

4.1 Executor

默认执行器:SimpleExecutor

public Executor newExecutor(Transaction transaction, ExecutorType executorType) {executorType = executorType == null ? defaultExecutorType : executorType;executorType = executorType == null ? ExecutorType.SIMPLE : executorType;Executor executor;if (ExecutorType.BATCH == executorType) {executor = new BatchExecutor(this, transaction);} else if (ExecutorType.REUSE == executorType) {executor = new ReuseExecutor(this, transaction);} else {executor = new SimpleExecutor(this, transaction);}if (cacheEnabled) {executor = new CachingExecutor(executor);}executor = (Executor) interceptorChain.pluginAll(executor);return executor;}

从代码中可以看到根据不同的执行器类型创建相应的执行器。
(1)SimpleExecutor:每执行一次update或select,就开启一个Statement对象,用完立刻关闭Statement对象。
(2)ReuseExecutor:执行update或select,以sql作为key查找Statement对象,存在就使用,不存在就创建,用完后,不关闭Statement对象,而是放置于Map内,供下一次使用。简言之,就是重复使用Statement对象。
(3)BatchExecutor:执行update(没有select,JDBC批处理不支持select),将所有sql都添加到批处理中(addBatch()),等待统一执行(executeBatch()),它缓存了多个Statement对象,每个Statement对象都是addBatch()完毕后,等待逐一执行executeBatch()批处理。与JDBC批处理相同。
(4)CachingExecutor:CachingExecutor是一个Executor接口的装饰器,它为Executor对象增加了二级缓存的相关功能,委托的执行器对象可以是SimpleExecutor、ReuseExecutor、BatchExecutor中任一一个。执行 update 方法前判断是否清空二级缓存;执行 query 方法前先在二级缓存中查询,命中失败再通过被代理类查询。

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

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

相关文章

亚马逊店铺解决和预防订单下滑的技巧

1. 保持账号的良好表现。不要销售侵权产品&#xff0c;发货要及时&#xff0c;能有追踪号的就带可查询追踪号&#xff0c;能发FBA的就通过FBA发货。 2. 持续做好产品优化工作&#xff0c;及时留意大环境的变化和平台政策变动。遇到编辑权限受限&#xff0c;可开case咨询或申请…

加快发展新质生产力!苏州金龙创新转型以“智”提“质”!

2024年3月6日&#xff0c;《科技日报》两会特刊“科技赋能强产业”系列刊发《新一代信息技术&#xff1a;筑牢数字经济高质量发展底座》&#xff0c;报道作为新质生产力重要体现的新一代信息技术&#xff0c;在推动科技创新、赋能产业发展方面影响深远。苏州金龙智能工厂图片出…

灭火新选择:便携式森林灭火泵,轻巧而强大

随着人类对自然环境的破坏&#xff0c;森林火灾频发&#xff0c;给生态环境和人民生命财产安全带来严重威胁。为了有效地应对森林火灾&#xff0c;恒峰研发出了一种便携式森林灭火泵&#xff0c;它将成为森林火灾的守护神。本文将详细介绍便携式森林灭火泵的特点、优势以及使用…

【armv8 / armv9】: MMU深度学习

文章目录 一、MMU概念介绍二、虚拟地址空间和物理地址空间2.1、(虚拟/物理)地址空间的范围2.2、物理地址空间有效位(范围) 三、Translation regimes四、地址翻译/几级页表&#xff1f;4.1、思考&#xff1a;页表到底有几级&#xff1f;4.2、以4KB granule为例&#xff0c;页表的…

【深度学习笔记】优化算法——Adam算法

Adam算法 &#x1f3f7;sec_adam 本章我们已经学习了许多有效优化的技术。 在本节讨论之前&#xff0c;我们先详细回顾一下这些技术&#xff1a; 在 :numref:sec_sgd中&#xff0c;我们学习了&#xff1a;随机梯度下降在解决优化问题时比梯度下降更有效。在 :numref:sec_min…

Jupyter Notebook使用教程——从Anaconda环境构建到Markdown、LaTex语法介绍

0. 前言 按照国际惯例&#xff0c;首先声明&#xff1a;本文只是我自己学习的理解&#xff0c;虽然参考了他人的宝贵见解及成果&#xff0c;但是内容可能存在不准确的地方。如果发现文中错误&#xff0c;希望批评指正&#xff0c;共同进步。 你是否在视频教程或说明文档或Githu…

运动想象 (MI) 迁移学习系列 (5) : SSMT

运动想象迁移学习系列:SSMT 0. 引言1. 主要贡献2. 网络结构3. 算法4. 补充4.1 为什么设置一种新的适配器&#xff1f;4.2 动态加权融合机制究竟是干啥的&#xff1f; 5. 实验结果6. 总结欢迎来稿 论文地址&#xff1a;https://link.springer.com/article/10.1007/s11517-024-0…

Linux之线程控制

目录 一、POSIX线程库 二、线程的创建 三、线程等待 四、线程终止 五、分离线程 六、线程ID&#xff1a;pthread_t 1、获取线程ID 2、pthread_t 七、线程局部存储&#xff1a;__thread 一、POSIX线程库 由于Linux下的线程并没有独立特有的结构&#xff0c;所以Linux并…

白炽灯护眼还是LED护眼?热门护眼台灯全方位实测推荐

白炽灯是制热发光体&#xff0c;电流通过发热时产生热量&#xff0c;灯丝温度达到2000摄氏度以上&#xff0c;灯丝处于白炽状态了&#xff0c;它的光电转换效率低&#xff0c;费电&#xff0c;寿命也比较短&#xff0c;最主要的一点是光线会比较集中刺眼&#xff0c;而且调节性…

Cassandra 安装部署

文章目录 一、概述1.官方文档2. 克隆服务器3.安装准备3.1.安装 JDK 113.2.安装 Python3.3.下载文件 二、安装部署1.配置 Cassandra2.启动 Cassandra3.关闭Cassandra4.查看状态5.客户端连接服务器6.服务运行脚本 开源中间件 # Cassandrahttps://iothub.org.cn/docs/middleware/…

深入理解Java多线程与线程池:提升程序性能的利器

✨✨谢谢大家捧场&#xff0c;祝屏幕前的小伙伴们每天都有好运相伴左右&#xff0c;一定要天天开心哦&#xff01;✨✨ &#x1f388;&#x1f388;作者主页&#xff1a; 喔的嘛呀&#x1f388;&#x1f388; 目录 引言 一、实现多线程 1.1. 继承Thread类 1.2. 实现Runnab…

趣学前端 | Taro迁移完成之后,总结了一些踩坑经验

背景 四月份的时候&#xff0c;尝试将老的移动端项目改造成多端。因为老项目使用的React框架&#xff0c;综合考量&#xff0c;保障当前业务开发的进度同时&#xff0c;进行项目迁移&#xff0c;所以最后选择了Taro框架。迁移成本会低一些&#xff0c;上手快一些。 上个月&am…