流程简单说明

  1. @MapperScan引入MapperScannerRegistrar注册一个MapperScannerConfigurerBeanDefinition对象
  2. MapperScannerConfigurer会扫描指定包的Mapper接口类,为Mapper接口类构建MapperFactoryBean
    BeanDefinition对象
  3. 当spring 初始化MapperFactoryBeanBean对象时,会调用FactoryBean # getObject() 方法,该方法会生成对应Mapper接口的org.apache.ibatis.binding.MapperProxy代理对象,spring会将该代理对象作为Bean对象存放到缓存中,所以我们才可以通过@Autowire引入。

@MapperScan

@MapperScan 注解中,引入了一个 MapperScannerRegistrar 注册器

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Import(MapperScannerRegistrar.class)
@Repeatable(MapperScans.class)
public @interface MapperScan {...
}

MapperScannerRegistrar

MapperScannerRegistrar 注册器 是一个 ImportBeanDefinitionRegistrar 实现类,用于注册 一个 MapperScannerConfigurerBeanDefinition 对象,并将@MapperScan中的配置信息添加到该BeanDefinitionPropertyValues

public class MapperScannerRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware {@Overridepublic void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {AnnotationAttributes mapperScanAttrs = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName()));if (mapperScanAttrs != null) {registerBeanDefinitions(importingClassMetadata, mapperScanAttrs, registry,generateBaseBeanName(importingClassMetadata, 0));}}void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes annoAttrs,BeanDefinitionRegistry registry, String beanName) {BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);//将@MapperScan中的配置信息添加到该BeanDefinition的PropertyValues中...registry.registerBeanDefinition(beanName, builder.getBeanDefinition());}
}

它就相当于以前的xml配置:

 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="org.mybatis.spring.sample.mapper" /><!-- optional unless there are multiple session factories defined --><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /></bean>

MapperScannerConfigurer

MapperScannerConfigurer 是一个 BeanDefinitionRegistryPostProcessor 实现类,主要用于注册 MapperFactoryBean 的BeanDefinition对象.

public class MapperScannerConfigurerimplements BeanDefinitionRegistryPostProcessor, InitializingBean, ApplicationContextAware, BeanNameAware {@Overridepublic void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {...ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);scanner.setAddToConfig(this.addToConfig);scanner.setAnnotationClass(this.annotationClass);scanner.setMarkerInterface(this.markerInterface);scanner.setSqlSessionFactory(this.sqlSessionFactory);scanner.setSqlSessionTemplate(this.sqlSessionTemplate);scanner.setSqlSessionFactoryBeanName(this.sqlSessionFactoryBeanName);scanner.setSqlSessionTemplateBeanName(this.sqlSessionTemplateBeanName);scanner.setResourceLoader(this.applicationContext);scanner.setBeanNameGenerator(this.nameGenerator);scanner.setMapperFactoryBeanClass(this.mapperFactoryBeanClass);if (StringUtils.hasText(lazyInitialization)) {scanner.setLazyInitialization(Boolean.valueOf(lazyInitialization));}scanner.registerFilters();scanner.scan(StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS));}
}

void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) 方法会新建一个 ClassPathMapperScanner 对象,通过 ClassPathMapperScanner 对象,除了将@MapperScan中的配置信息配置进去以外,通过 ClassPathMapperScanner # scan(String... basePackages) 方法进行扫描指定包的Mapper 层接口类 并注册 MapperFactoryBeanBeanDefinition 对象。
scan(String... basePackages)ClassPathMapperScanner 的父类ClassPathBeanDefinitionScanner方法

public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateComponentProvider {
/*** Perform a scan within the specified base packages.* @param basePackages the packages to check for annotated classes* @return number of beans registered*/public int scan(String... basePackages) {int beanCountAtScanStart = this.registry.getBeanDefinitionCount();doScan(basePackages);// Register annotation config processors, if necessary.if (this.includeAnnotationConfig) {AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry);}return (this.registry.getBeanDefinitionCount() - beanCountAtScanStart);}
/*** Perform a scan within the specified base packages,* returning the registered bean definitions.* <p>This method does <i>not</i> register an annotation config processor* but rather leaves this up to the caller.* @param basePackages the packages to check for annotated classes* @return set of beans registered if any for tooling registration purposes (never {@code null})*/protected Set<BeanDefinitionHolder> doScan(String... basePackages) {Assert.notEmpty(basePackages, "At least one base package must be specified");Set<BeanDefinitionHolder> beanDefinitions = new LinkedHashSet<>();for (String basePackage : basePackages) {Set<BeanDefinition> candidates = findCandidateComponents(basePackage);for (BeanDefinition candidate : candidates) {ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);candidate.setScope(scopeMetadata.getScopeName());String beanName = this.beanNameGenerator.generateBeanName(candidate, this.registry);if (candidate instanceof AbstractBeanDefinition) {postProcessBeanDefinition((AbstractBeanDefinition) candidate, beanName);}if (candidate instanceof AnnotatedBeanDefinition) {AnnotationConfigUtils.processCommonDefinitionAnnotations((AnnotatedBeanDefinition) candidate);}if (checkCandidate(beanName, candidate)) {BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(candidate, beanName);definitionHolder =AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);beanDefinitions.add(definitionHolder);registerBeanDefinition(definitionHolder, this.registry);}}}return beanDefinitions;}
}

ClassPathMapperScanner 重写了 ClassPathBeanDefinitionScanner # doScan(String ... basePackages) 方法,再通过父级方法扫描完指定包名得到 BeanDefinitionHolder 列表后,对这个 BeanDefinitionHolder 进行处理

public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {@Overridepublic Set<BeanDefinitionHolder> doScan(String... basePackages) {Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);if (beanDefinitions.isEmpty()) {LOGGER.warn(() -> "No MyBatis mapper was found in '" + Arrays.toString(basePackages)+ "' package. Please check your configuration.");} else {processBeanDefinitions(beanDefinitions);}return beanDefinitions;}private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {GenericBeanDefinition definition;for (BeanDefinitionHolder holder : beanDefinitions) {definition = (GenericBeanDefinition) holder.getBeanDefinition();String beanClassName = definition.getBeanClassName();LOGGER.debug(() -> "Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + beanClassName+ "' mapperInterface");// the mapper interface is the original class of the bean// but, the actual class of the bean is MapperFactoryBeandefinition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName); // issue #59definition.setBeanClass(this.mapperFactoryBeanClass);definition.getPropertyValues().add("addToConfig", this.addToConfig);boolean explicitFactoryUsed = false;if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {definition.getPropertyValues().add("sqlSessionFactory",new RuntimeBeanReference(this.sqlSessionFactoryBeanName));explicitFactoryUsed = true;} else if (this.sqlSessionFactory != null) {definition.getPropertyValues().add("sqlSessionFactory", this.sqlSessionFactory);explicitFactoryUsed = true;}if (StringUtils.hasText(this.sqlSessionTemplateBeanName)) {if (explicitFactoryUsed) {LOGGER.warn(() -> "Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");}definition.getPropertyValues().add("sqlSessionTemplate",new RuntimeBeanReference(this.sqlSessionTemplateBeanName));explicitFactoryUsed = true;} else if (this.sqlSessionTemplate != null) {if (explicitFactoryUsed) {LOGGER.warn(() -> "Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");}definition.getPropertyValues().add("sqlSessionTemplate", this.sqlSessionTemplate);explicitFactoryUsed = true;}if (!explicitFactoryUsed) {LOGGER.debug(() -> "Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'.");definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);}definition.setLazyInit(lazyInitialization);}}
}

processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions)中,遍历 beanDefinitions 的所有BeanDefinitionHolder 对象,取出 BeanDefinitionHolder 对象的 BeanDefinition 对象,修改 BeanDefinition 对象的 beanClass 属性为MapperFactoryBean.class,并增加了构造方法参数对象beanClassName,beanClassNameBeanDefinition 对象中原来的 beanClass的类名,原来的beanClass其实 Mapper 层的接口类。
这里其实相当于以前xml配置:

  <bean id="baseMapper" class="org.mybatis.spring.mapper.MapperFactoryBean" abstract="true" lazy-init="true"><property name="sqlSessionFactory" ref="sqlSessionFactory" /></bean><bean id="oneMapper" parent="baseMapper"><property name="mapperInterface" value="my.package.MyMapperInterface" /></bean><bean id="anotherMapper" parent="baseMapper"><property name="mapperInterface" value="my.package.MyAnotherMapperInterface" /></bean>

MapperFactoryBean

MapperFactoryBean 是一个 FactoryBean,它只有一个接收一个Class<?> 对象的构造方法。该Class<?>对象对应 MapperFactoryBeanmapperInterface 属性,该属性就是 Mapper 层的Mapper接口类。

SqlSessionDaoSupport

MapperFactoryBean 继承了 SqlSessionDaoSupport , spring 会对SqlSessionDaoSupport自动装配SqlSessionFactory,然后SqlSessionDaoSupport会使用SqlSessionFactory创建出SqlSessionTemplate对象。

public abstract class SqlSessionDaoSupport extends DaoSupport {private SqlSessionTemplate sqlSessionTemplate;/*** Set MyBatis SqlSessionFactory to be used by this DAO. Will automatically create SqlSessionTemplate for the given* SqlSessionFactory.** @param sqlSessionFactory*          a factory of SqlSession*/public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {if (this.sqlSessionTemplate == null || sqlSessionFactory != this.sqlSessionTemplate.getSqlSessionFactory()) {this.sqlSessionTemplate = createSqlSessionTemplate(sqlSessionFactory);}}/*** Create a SqlSessionTemplate for the given SqlSessionFactory. Only invoked if populating the DAO with a* SqlSessionFactory reference!* <p>* Can be overridden in subclasses to provide a SqlSessionTemplate instance with different configuration, or a custom* SqlSessionTemplate subclass.* * @param sqlSessionFactory*          the MyBatis SqlSessionFactory to create a SqlSessionTemplate for* @return the new SqlSessionTemplate instance* @see #setSqlSessionFactory*/@SuppressWarnings("WeakerAccess")protected SqlSessionTemplate createSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}/*** Return the MyBatis SqlSessionFactory used by this DAO.** @return a factory of SqlSession*/public final SqlSessionFactory getSqlSessionFactory() {return (this.sqlSessionTemplate != null ? this.sqlSessionTemplate.getSqlSessionFactory() : null);}/*** Set the SqlSessionTemplate for this DAO explicitly, as an alternative to specifying a SqlSessionFactory.** @param sqlSessionTemplate*          a template of SqlSession* @see #setSqlSessionFactory*/public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {this.sqlSessionTemplate = sqlSessionTemplate;}/*** Users should use this method to get a SqlSession to call its statement methods This is SqlSession is managed by* spring. Users should not commit/rollback/close it because it will be automatically done.** @return Spring managed thread safe SqlSession*/public SqlSession getSqlSession() {return this.sqlSessionTemplate;}/*** Return the SqlSessionTemplate for this DAO, pre-initialized with the SessionFactory or set explicitly.* <p>* <b>Note: The returned SqlSessionTemplate is a shared instance.</b> You may introspect its configuration, but not* modify the configuration (other than from within an {@link #initDao} implementation). Consider creating a custom* SqlSessionTemplate instance via {@code new SqlSessionTemplate(getSqlSessionFactory())}, in which case you're* allowed to customize the settings on the resulting instance.** @return a template of SqlSession*/public SqlSessionTemplate getSqlSessionTemplate() {return this.sqlSessionTemplate;}/*** {@inheritDoc}*/@Overrideprotected void checkDaoConfig() {notNull(this.sqlSessionTemplate, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");}}

DaoSupport

除此之外, SqlSessionDaoSupport还继承了DaoSupport,而 DaoSupport 实现 InitializingBean接口,在Spring 初始化MapperFactoryBean对象,会触发 DaoSupport # afterPropertiesSet() 方法,从而回到DaoSupport # checkDaoConfig() 方法,在DaoSupport # checkDaoConfig()中:

  1. SqlSessionSupport中会检查sqlSessionTemplate对象是否为null,如果为null说明SqlSessionFactory未被装配尽量,这将会导致抛出异常。
  2. MapperFactoryBean会检查sqlSessionTemplate所维护的Configuration对象【Configuration就相当于Mybatis的注册中心,里面包含所有Mybatis的配置信息,Mapper层的配置信息/元数据等】中有没有注册过mapperInterface的Mapper层,没有就会将mapperInterface注册进去。
public abstract class DaoSupport implements InitializingBean {/** Logger available to subclasses. */protected final Log logger = LogFactory.getLog(getClass());@Overridepublic final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException {// Let abstract subclasses check their configuration.checkDaoConfig();// Let concrete implementations initialize themselves.try {initDao();}catch (Exception ex) {throw new BeanInitializationException("Initialization of DAO failed", ex);}}/*** Abstract subclasses must override this to check their configuration.* <p>Implementors should be marked as {@code final} if concrete subclasses* are not supposed to override this template method themselves.* @throws IllegalArgumentException in case of illegal configuration*/protected abstract void checkDaoConfig() throws IllegalArgumentException;/*** Concrete subclasses can override this for custom initialization behavior.* Gets called after population of this instance's bean properties.* @throws Exception if DAO initialization fails* (will be rethrown as a BeanInitializationException)* @see org.springframework.beans.factory.BeanInitializationException*/protected void initDao() throws Exception {}}

MapperFactoryBean # getObject()

MapperFactoryBean被Spring初始化后,就会调用MapperFactoryBean # getObject() 方法,该方法会使用sqlSessionTemplate构建出mapperInterface的代理对象。Spring会FactoryBean # getObject()返回的对象封装成Bean对象,所以我们可以通过 @Autowire自动装配进来。
该代理对象就是 org.apache.ibatis.binding.MapperProxy对象,当调用接口方法时,MapperProxy会从Configuration中获取与之对应的MapperStatement对象进行执行。

public class MapperFactoryBean<T> extends SqlSessionDaoSupport implements FactoryBean<T> {private Class<T> mapperInterface;private boolean addToConfig = true;public MapperFactoryBean() {// intentionally empty}public MapperFactoryBean(Class<T> mapperInterface) {this.mapperInterface = mapperInterface;}/*** {@inheritDoc}*/@Overrideprotected void checkDaoConfig() {super.checkDaoConfig();notNull(this.mapperInterface, "Property 'mapperInterface' is required");Configuration configuration = getSqlSession().getConfiguration();if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {try {configuration.addMapper(this.mapperInterface);} catch (Exception e) {logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", e);throw new IllegalArgumentException(e);} finally {ErrorContext.instance().reset();}}}/*** {@inheritDoc}*/@Overridepublic T getObject() throws Exception {return getSqlSession().getMapper(this.mapperInterface);}/*** {@inheritDoc}*/@Overridepublic Class<T> getObjectType() {return this.mapperInterface;}/*** {@inheritDoc}*/@Overridepublic boolean isSingleton() {return true;}// ------------- mutators --------------/*** Sets the mapper interface of the MyBatis mapper** @param mapperInterface*          class of the interface*/public void setMapperInterface(Class<T> mapperInterface) {this.mapperInterface = mapperInterface;}/*** Return the mapper interface of the MyBatis mapper** @return class of the interface*/public Class<T> getMapperInterface() {return mapperInterface;}/*** If addToConfig is false the mapper will not be added to MyBatis. This means it must have been included in* mybatis-config.xml.* <p>* If it is true, the mapper will be added to MyBatis in the case it is not already registered.* <p>* By default addToConfig is true.** @param addToConfig*          a flag that whether add mapper to MyBatis or not*/public void setAddToConfig(boolean addToConfig) {this.addToConfig = addToConfig;}/*** Return the flag for addition into MyBatis config.** @return true if the mapper will be added to MyBatis in the case it is not already registered.*/public boolean isAddToConfig() {return addToConfig;}
}

可能会有读者疑问,为什么在 MapperScannerConfigurer 中所生成的 MapperFactoryBeanBeanDefnition 对象所配置的构造函数参数是一个String类型的 Mapper 层接口类名。但是 MapperFactoryBean 是只接受Class<?>对象,为啥还能成功构建出 MapperFactoryBean 对象 呢?
因为 Spring 可以自动匹配对应依赖类型,尽可能对能转换成依赖类型的对象进行转换。具体代码情况 AbstractAutowireCapableBeanFactory # createBeanInstance(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) 方法,该方法会使用ConstructResolver找到最匹配的构造函数方法,然后通过TypeConverter尽可能地转换构造函数参数为依赖类型。温馨提示:MapperFactoryBeanBeanDefinition对象的构造函数参数值通过TypeConverter进行转换成Class<?>其实是通过 PropertyEditorRegistry的默认内置PropertyEditorClassEditor进行转换的。

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

相关文章

  1. 最小生成树之Prim算法,浅显易懂

    Prim算法主要思路&#xff1a; 抽象&#xff08;假想:假设存在&#xff0c;但不存在&#xff09;出两个集合&#xff0c;V 和Vnew 最开始&#xff0c;所以的图节点都在集合V中如果一个节点加入到了最小生成树中&#xff0c;则将该节点加入到Vnew(即Vnew保存的是最小生成树中的…...

    2024/4/21 21:30:38
  2. Postman发送post请求

    ** Postman发送post请求 阿源是个女程序员~ ** 在服务器开发过程中&#xff0c;要经常对get,post接口进行测试&#xff0c;get请求&#xff0c;浏览器就可以完成&#xff0c;而post请求浏览器用起来有点麻烦&#xff0c;有的浏览器支持的不太好&#xff0c;个人用过火狐&…...

    2024/4/21 21:30:37
  3. C++ 编译过程

    C语言的编译链接过程要把我们编写的一个c程序&#xff08;源代码&#xff09;转换成可以在硬件上运行的程序&#xff08;可执行代码&#xff09;&#xff0c;需要进行编译和链接。编译就是把文本形式源代码翻译为机器语言形式的目标文件的过程。链接是把目标文件、操作系统的启…...

    2024/4/21 21:30:37
  4. Function.prototype.apply()的使用和实现

    文章目录Function.prototypeapply()的语法一些使用例子找出数组最大值设置函数上下文构造属性继承手动实现一个apply()参考资料Function.prototype Function.prototype.apply() 在一个对象的上下文中应用另一个对象的方法&#xff1b;参数能够以数组形式传入。 Function.pro…...

    2024/5/3 4:30:56
  5. 教你快速去掉VC运行环境下的Press any key to continue

    问题 当我们运行c文件时&#xff0c;默认都会显示Press any key to continue这句话 那我们怎么让这句话不显示呢&#xff1f; 解决方案 答案很简单&#xff0c;只需在程序末尾加一行**getch();**代码即可 注意加头文件conio.h #include<stdio.h> #include<conio.…...

    2024/4/29 4:49:15
  6. SQL查询语句

    Where查询子句练习 select * from order_info_table where product_id between 1002 and 1003; select * from order_info_table where user_id in (1,3,5); select * from order_info_table where order_status‘pay’; select * from order_info_table where user_name li…...

    2024/5/3 3:52:42
  7. 封装jsonp

    // jsonp是解决跨域的一种方法&#xff0c;它利用script标签中的src访问不同源的数据不受同源策略的限制&#xff0c;在src的值中包裹了一个回调函数名&#xff0c;服务器接收到该请求后向该回调函数封装客户端所要请求的数据&#xff0c;由客户端定义的处理函数来处理接收到的…...

    2024/4/21 21:30:33
  8. Stem教育课程模式是有机地整合

    现行的STEM教育课程模式&#xff0c;强调各个领域之间的关联。不是简单将各个领域拼凑在一起&#xff0c;而是有目的、有方法、有系统的组合。科学与工程问题往往是课程的主要线索&#xff0c;围绕主线创造一个多维空间&#xff0c;从而为学生提供一系列具有一定程度关联性的学…...

    2024/4/21 21:30:31
  9. Spring Cloud第四天

    Ribbon &#xff08;负载均衡服务调用&#xff0c;适用于消费者模块&#xff09;&#xff1a;&#xff08;底层Httpclient&#xff09; 是什么 能干嘛 总结&#xff1a; Ribbon工作原理 使用Ribbon的步骤&#xff1a; 1、改pom.xml 2、使用RestTemplate: SpringCloud Res…...

    2024/4/21 21:30:30
  10. Halcon:c++异常处理

    try {//run halcon function in c } catch (HException &exception) {fprintf(stderr," Error #%u in %s: %s\n", exception.ErrorCode(),(const char *)exception.ProcName(),(const char *)exception.ErrorMessage()); }...

    2024/4/21 21:30:29
  11. 开发一套Java多用户商城系统多少钱

    如果不考虑二次开发,不考虑购买授权, 你可以按人工成本来计算, 比如4个Java程序员,2个前端程序员,开发6个月, 假设每个程序员平均月薪为8千,算下来就是:(42)*8*628.8万. 感觉这个价位也比较合理。 这可能是一个PC前端和后台的功能开发&#xff0c; 首版整体质量和功能不一…...

    2024/4/21 18:33:06
  12. Keepalived-短信告警(四)

    keepalived-短信告警 1. centos7.6 mailx服务 1.安装mailx服务 yum -y install mailx2.配置邮箱 set bsdcompat set fromxxxxxqq.com set smtpsmtp.qq.com set smtp-auth-userxxxxxqq.com set smtp-auth-passwordkgpzotzvxtjofedi ##口令 set smtp-authlogin3.验证是否可…...

    2024/5/3 0:37:58
  13. WEB前端面试题--js面试题(高级)相关总结题目

    JavaScript 进阶面试题 说 说说 说 ECMAScript6 怎么写 class? 这个语法糖可以让有 OOP 基础的人更快上手 js &#xff0c;至少是一个官方的实现了。 对熟悉 js 的人来说&#xff0c;这个东西没啥大影响&#xff1b;一个 Object.creat() 搞定继承&#xff0c;比 class 简洁 清…...

    2024/4/21 21:17:37
  14. LC-3学习记录(一)

    啥是LC-3? LC-3是一种简单&#xff08;可能&#xff1f;&#xff09;的十六位机器语言&#xff0c;它具有没什么卵用且可能使您挂科的作用。该语言自发明以来饱受欢迎&#xff0c;它受欢迎就体现在它受欢迎个锤子的欢迎&#xff0c;内网外网啥资料找不到它受欢迎它受了个蔡徐坤…...

    2024/4/21 21:17:35
  15. Vue细节之$data的细节

    前言 $data是Vue实例中的实例属性&#xff0c;表示Vue实例观察的数据对象。实际上在Vue官网对这部分有较为详细的描述&#xff0c;这里就不再赘述了&#xff08;具体可看官网的描述Vue选项/数据&#xff09;。本篇文章从源码层次来梳理$data背后的逻辑&#xff0c;实际上就是一…...

    2024/5/2 5:07:24
  16. 【Spring Boot】009-Spring Boot整合Druid数据源

    目录 一、Druid简介 Github地址&#xff1a; com.alibaba.druid.pool.DruidDataSource 基本配置参数如下&#xff1a; 二、配置数据源 1、简单配置 第一步&#xff1a;导入Maven坐标 第二步&#xff1a;切换数据源 第三步&#xff1a;添加其他配置 第四步&#xff1a;…...

    2024/4/29 7:04:01
  17. 2020-9-16

    //严蔚敏《数据结构》 //链栈是特殊的链表&#xff0c;只能对栈顶元素进行操作 //清空Clear应该可以从栈底元素开始吧&#xff1f;不然单链表不好清空啊&#xff0c;如果是双向链表比较容易从栈顶遍历到栈底 //链栈 数据结构书中无太多介绍 //自学数据结构中&#xff0c;加油&a…...

    2024/4/24 23:39:05
  18. c#自定义类的集合运算(Distinct, Except, Intersect, Union)

    参考&#xff1a; 1、自定义比较函数–https://stackoverflow.com/questions/12988209/list-except-is-not-working 2、集合运算–https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/set-operations 进行集合运算时&#xff0c;linq需要比较集…...

    2024/4/28 13:20:14
  19. Windows server 2016加域(随手笔记)

    Windows server 2016加入域准备好域控服务器A.域控服务器B.域控服务器网关开始加域1.指定域地址2.配置网关3.确认是否能ping通域控服务器地址4.开始加域准备好域控服务器 A.域控服务器 B.域控服务器网关 开始加域 1.指定域地址 指定域地址文件路径&#xff1a;C:\Windows\Sy…...

    2024/4/21 21:17:30
  20. 获取动态渲染table中的input的值

    由于时间关系就截个图吧 如果看懂了说明你悟性好~ 页面大概是这个样纸的 如下图...

    2024/4/21 21:17:29

最新文章

  1. C语言双向链表快速入门教程

    链表的声明 double_linked_list.h #ifndef ZDPC_ALGORITHM_DEV_DOUBLE_LINKED_LIST_H #define ZDPC_ALGORITHM_DEV_DOUBLE_LINKED_LIST_H// 双向链表的节点 typedef struct doubleLinkedListNode {int data;struct doubleLinkedListNode *next; // 下一个节点struct doubleLi…...

    2024/5/3 6:50:10
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 零基础 HTML 入门(详细)

    目录 1.简介 1.1 HTML是什么? 1.2 HTML 版本 1.3 通用声明 2.HTML 编辑器 3.标签的语法 4.HTML属性 5.常用标签 5.1 head 元素 5.1.1 title 标签 5.1.2 base 标签 5.1.3 link 标签 5.1.4 style 标签 5.1.5 meta 标签 5.1.6 script 5.2 HTML 注释 5.3 段落标签…...

    2024/5/1 13:12:05
  4. 【超简单】基于PaddleSpeech搭建个人语音听写服务

    一、【超简单】之基于PaddleSpeech搭建个人语音听写服务 1.需求分析 亲们,你们要写会议纪要嘛?亲们,你们要写会议纪要嘛?亲们,你们要写会议纪要嘛?当您面对成吨的会议录音,着急写会议纪要而不得不愚公移山、人海战术?听的头晕眼花,听的漏洞百出,听的怀疑人生,那么你…...

    2024/5/2 17:17:32
  5. 416. 分割等和子集问题(动态规划)

    题目 题解 class Solution:def canPartition(self, nums: List[int]) -> bool:# badcaseif not nums:return True# 不能被2整除if sum(nums) % 2 ! 0:return False# 状态定义&#xff1a;dp[i][j]表示当背包容量为j&#xff0c;用前i个物品是否正好可以将背包填满&#xff…...

    2024/5/2 11:19:01
  6. 【Java】ExcelWriter自适应宽度工具类(支持中文)

    工具类 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;/*** Excel工具类** author xiaoming* date 2023/11/17 10:40*/ public class ExcelUti…...

    2024/5/2 16:04:58
  7. Spring cloud负载均衡@LoadBalanced LoadBalancerClient

    LoadBalance vs Ribbon 由于Spring cloud2020之后移除了Ribbon&#xff0c;直接使用Spring Cloud LoadBalancer作为客户端负载均衡组件&#xff0c;我们讨论Spring负载均衡以Spring Cloud2020之后版本为主&#xff0c;学习Spring Cloud LoadBalance&#xff0c;暂不讨论Ribbon…...

    2024/5/2 23:55:17
  8. TSINGSEE青犀AI智能分析+视频监控工业园区周界安全防范方案

    一、背景需求分析 在工业产业园、化工园或生产制造园区中&#xff0c;周界防范意义重大&#xff0c;对园区的安全起到重要的作用。常规的安防方式是采用人员巡查&#xff0c;人力投入成本大而且效率低。周界一旦被破坏或入侵&#xff0c;会影响园区人员和资产安全&#xff0c;…...

    2024/5/2 9:47:31
  9. VB.net WebBrowser网页元素抓取分析方法

    在用WebBrowser编程实现网页操作自动化时&#xff0c;常要分析网页Html&#xff0c;例如网页在加载数据时&#xff0c;常会显示“系统处理中&#xff0c;请稍候..”&#xff0c;我们需要在数据加载完成后才能继续下一步操作&#xff0c;如何抓取这个信息的网页html元素变化&…...

    2024/5/2 9:47:31
  10. 【Objective-C】Objective-C汇总

    方法定义 参考&#xff1a;https://www.yiibai.com/objective_c/objective_c_functions.html Objective-C编程语言中方法定义的一般形式如下 - (return_type) method_name:( argumentType1 )argumentName1 joiningArgument2:( argumentType2 )argumentName2 ... joiningArgu…...

    2024/5/2 6:03:07
  11. 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】

    &#x1f468;‍&#x1f4bb;博客主页&#xff1a;花无缺 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! 本文由 花无缺 原创 收录于专栏 【洛谷算法题】 文章目录 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】&#x1f30f;题目描述&#x1f30f;输入格…...

    2024/5/2 9:47:30
  12. 【ES6.0】- 扩展运算符(...)

    【ES6.0】- 扩展运算符... 文章目录 【ES6.0】- 扩展运算符...一、概述二、拷贝数组对象三、合并操作四、参数传递五、数组去重六、字符串转字符数组七、NodeList转数组八、解构变量九、打印日志十、总结 一、概述 **扩展运算符(...)**允许一个表达式在期望多个参数&#xff0…...

    2024/5/2 23:47:43
  13. 摩根看好的前智能硬件头部品牌双11交易数据极度异常!——是模式创新还是饮鸩止渴?

    文 | 螳螂观察 作者 | 李燃 双11狂欢已落下帷幕&#xff0c;各大品牌纷纷晒出优异的成绩单&#xff0c;摩根士丹利投资的智能硬件头部品牌凯迪仕也不例外。然而有爆料称&#xff0c;在自媒体平台发布霸榜各大榜单喜讯的凯迪仕智能锁&#xff0c;多个平台数据都表现出极度异常…...

    2024/5/2 5:31:39
  14. Go语言常用命令详解(二)

    文章目录 前言常用命令go bug示例参数说明 go doc示例参数说明 go env示例 go fix示例 go fmt示例 go generate示例 总结写在最后 前言 接着上一篇继续介绍Go语言的常用命令 常用命令 以下是一些常用的Go命令&#xff0c;这些命令可以帮助您在Go开发中进行编译、测试、运行和…...

    2024/5/3 1:55:15
  15. 用欧拉路径判断图同构推出reverse合法性:1116T4

    http://cplusoj.com/d/senior/p/SS231116D 假设我们要把 a a a 变成 b b b&#xff0c;我们在 a i a_i ai​ 和 a i 1 a_{i1} ai1​ 之间连边&#xff0c; b b b 同理&#xff0c;则 a a a 能变成 b b b 的充要条件是两图 A , B A,B A,B 同构。 必要性显然&#xff0…...

    2024/5/2 9:47:28
  16. 【NGINX--1】基础知识

    1、在 Debian/Ubuntu 上安装 NGINX 在 Debian 或 Ubuntu 机器上安装 NGINX 开源版。 更新已配置源的软件包信息&#xff0c;并安装一些有助于配置官方 NGINX 软件包仓库的软件包&#xff1a; apt-get update apt install -y curl gnupg2 ca-certificates lsb-release debian-…...

    2024/5/2 9:47:27
  17. Hive默认分割符、存储格式与数据压缩

    目录 1、Hive默认分割符2、Hive存储格式3、Hive数据压缩 1、Hive默认分割符 Hive创建表时指定的行受限&#xff08;ROW FORMAT&#xff09;配置标准HQL为&#xff1a; ... ROW FORMAT DELIMITED FIELDS TERMINATED BY \u0001 COLLECTION ITEMS TERMINATED BY , MAP KEYS TERMI…...

    2024/5/3 1:55:09
  18. 【论文阅读】MAG:一种用于航天器遥测数据中有效异常检测的新方法

    文章目录 摘要1 引言2 问题描述3 拟议框架4 所提出方法的细节A.数据预处理B.变量相关分析C.MAG模型D.异常分数 5 实验A.数据集和性能指标B.实验设置与平台C.结果和比较 6 结论 摘要 异常检测是保证航天器稳定性的关键。在航天器运行过程中&#xff0c;传感器和控制器产生大量周…...

    2024/5/2 8:37:00
  19. --max-old-space-size=8192报错

    vue项目运行时&#xff0c;如果经常运行慢&#xff0c;崩溃停止服务&#xff0c;报如下错误 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 因为在 Node 中&#xff0c;通过JavaScript使用内存时只能使用部分内存&#xff08;64位系统&…...

    2024/5/2 9:47:26
  20. 基于深度学习的恶意软件检测

    恶意软件是指恶意软件犯罪者用来感染个人计算机或整个组织的网络的软件。 它利用目标系统漏洞&#xff0c;例如可以被劫持的合法软件&#xff08;例如浏览器或 Web 应用程序插件&#xff09;中的错误。 恶意软件渗透可能会造成灾难性的后果&#xff0c;包括数据被盗、勒索或网…...

    2024/5/2 9:47:25
  21. JS原型对象prototype

    让我简单的为大家介绍一下原型对象prototype吧&#xff01; 使用原型实现方法共享 1.构造函数通过原型分配的函数是所有对象所 共享的。 2.JavaScript 规定&#xff0c;每一个构造函数都有一个 prototype 属性&#xff0c;指向另一个对象&#xff0c;所以我们也称为原型对象…...

    2024/5/2 23:47:16
  22. C++中只能有一个实例的单例类

    C中只能有一个实例的单例类 前面讨论的 President 类很不错&#xff0c;但存在一个缺陷&#xff1a;无法禁止通过实例化多个对象来创建多名总统&#xff1a; President One, Two, Three; 由于复制构造函数是私有的&#xff0c;其中每个对象都是不可复制的&#xff0c;但您的目…...

    2024/5/2 18:46:52
  23. python django 小程序图书借阅源码

    开发工具&#xff1a; PyCharm&#xff0c;mysql5.7&#xff0c;微信开发者工具 技术说明&#xff1a; python django html 小程序 功能介绍&#xff1a; 用户端&#xff1a; 登录注册&#xff08;含授权登录&#xff09; 首页显示搜索图书&#xff0c;轮播图&#xff0…...

    2024/5/2 7:30:11
  24. 电子学会C/C++编程等级考试2022年03月(一级)真题解析

    C/C++等级考试(1~8级)全部真题・点这里 第1题:双精度浮点数的输入输出 输入一个双精度浮点数,保留8位小数,输出这个浮点数。 时间限制:1000 内存限制:65536输入 只有一行,一个双精度浮点数。输出 一行,保留8位小数的浮点数。样例输入 3.1415926535798932样例输出 3.1…...

    2024/5/3 1:54:59
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57