spring.boot 随笔0 springFactoriesInstance入门

0. 其实也没有那么入门

明天还要上班,速度write,直接放一张多样性比较好的 spring.factories 文件(取自 spring-boot-2.3.4.RELEASE.jar)

# PropertySource Loaders
org.springframework.boot.env.PropertySourceLoader=\
org.springframework.boot.env.PropertiesPropertySourceLoader,\
org.springframework.boot.env.YamlPropertySourceLoader# Run Listeners
org.springframework.boot.SpringApplicationRunListener=\
org.springframework.boot.context.event.EventPublishingRunListener# Error Reporters
org.springframework.boot.SpringBootExceptionReporter=\
org.springframework.boot.diagnostics.FailureAnalyzers# Application Context Initializers
org.springframework.context.ApplicationContextInitializer=\
org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer,\
org.springframework.boot.context.ContextIdApplicationContextInitializer,\
org.springframework.boot.context.config.DelegatingApplicationContextInitializer,\
org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer,\
org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer# Application Listeners
org.springframework.context.ApplicationListener=\
org.springframework.boot.ClearCachesApplicationListener,\
org.springframework.boot.builder.ParentContextCloserApplicationListener,\
org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor,\
org.springframework.boot.context.FileEncodingApplicationListener,\
org.springframework.boot.context.config.AnsiOutputApplicationListener,\
org.springframework.boot.context.config.ConfigFileApplicationListener,\
org.springframework.boot.context.config.DelegatingApplicationListener,\
org.springframework.boot.context.logging.ClasspathLoggingApplicationListener,\
org.springframework.boot.context.logging.LoggingApplicationListener,\
org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor,\
org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor,\
org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor,\
org.springframework.boot.reactor.DebugAgentEnvironmentPostProcessor# Failure Analyzers
org.springframework.boot.diagnostics.FailureAnalyzer=\
org.springframework.boot.context.properties.NotConstructorBoundInjectionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanDefinitionOverrideFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.UnboundConfigurationPropertyFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.PortInUseFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyNameFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyValueFailureAnalyzer# FailureAnalysisReporters
org.springframework.boot.diagnostics.FailureAnalysisReporter=\
org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter

本文主要从几个简单、常见的 springFactoriesInstance 说起,暂时不会覆盖所有的

1. ApplicationContextInitializer

请添加图片描述

1.1 注册

顺路注释了 事件监听器 相关的注册、应用方法

	// org.springframework.boot.SpringApplication#SpringApplication(org.springframework.core.io.ResourceLoader, java.lang.Class<?>...)public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {this.resourceLoader = resourceLoader;Assert.notNull(primarySources, "PrimarySources must not be null");this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));this.webApplicationType = WebApplicationType.deduceFromClasspath();// step into ...// 在构造的时候注册,可见优先级之高// 就是将方法返回的结果直接赋值而已setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));// 应用监听器也在这里,并且调用路径完全一致setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));this.mainApplicationClass = deduceMainApplicationClass();}-------------// org.springframework.boot.SpringApplication#getSpringFactoriesInstances(java.lang.Class<T>)private <T> Collection<T> getSpringFactoriesInstances(Class<T> type) {// step into ...return getSpringFactoriesInstances(type, new Class<?>[] {});}private <T> Collection<T> getSpringFactoriesInstances(Class<T> type, Class<?>[] parameterTypes, Object... args) {ClassLoader classLoader = getClassLoader();// Use names and ensure unique to protect against duplicatesSet<String> names = new LinkedHashSet<>(SpringFactoriesLoader.loadFactoryNames(type, classLoader));List<T> instances = createSpringFactoriesInstances(type, parameterTypes, classLoader, args, names);AnnotationAwareOrderComparator.sort(instances);return instances;}

1.2 应用

/** Copyright 2002-2018 the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      https://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package org.springframework.context;/*** Callback interface for initializing a Spring {@link ConfigurableApplicationContext}* prior to being {@linkplain ConfigurableApplicationContext#refresh() refreshed}.** <p>Typically used within web applications that require some programmatic initialization* of the application context. For example, registering property sources or activating* profiles against the {@linkplain ConfigurableApplicationContext#getEnvironment()* context's environment}. See {@code ContextLoader} and {@code FrameworkServlet} support* for declaring a "contextInitializerClasses" context-param and init-param, respectively.** <p>{@code ApplicationContextInitializer} processors are encouraged to detect* whether Spring's {@link org.springframework.core.Ordered Ordered} interface has been* implemented or if the @{@link org.springframework.core.annotation.Order Order}* annotation is present and to sort instances accordingly if so prior to invocation.** @author Chris Beams* @since 3.1* @param <C> the application context type* @see org.springframework.web.context.ContextLoader#customizeContext* @see org.springframework.web.context.ContextLoader#CONTEXT_INITIALIZER_CLASSES_PARAM* @see org.springframework.web.servlet.FrameworkServlet#setContextInitializerClasses* @see org.springframework.web.servlet.FrameworkServlet#applyInitializers*/
public interface ApplicationContextInitializer<C extends ConfigurableApplicationContext> {// 它发挥作用的地方就这一个了/*** Initialize the given application context.* @param applicationContext the application to configure*/void initialize(C applicationContext);}-----------------// org.springframework.boot.SpringApplication#run(java.lang.String...)public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();configureHeadlessProperty();SpringApplicationRunListeners listeners = getRunListeners(args);listeners.starting();try {ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);Banner printedBanner = printBanner(environment);context = createApplicationContext();exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);// step into ...// 就在初始化之前!prepareContext(context, environment, listeners, applicationArguments, printedBanner);// 可以作为参照点,大家都再熟悉不过了refreshContext(context);afterRefresh(context, applicationArguments);stopWatch.stop();if (this.logStartupInfo) {new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);}listeners.started(context);callRunners(context, applicationArguments);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, listeners);throw new IllegalStateException(ex);}try {listeners.running(context);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, null);throw new IllegalStateException(ex);}return context;}-------------// org.springframework.boot.SpringApplication#prepareContextprivate void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment,SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {context.setEnvironment(environment);postProcessApplicationContext(context);// step into ...// 也算见名知意applyInitializers(context);listeners.contextPrepared(context);if (this.logStartupInfo) {logStartupInfo(context.getParent() == null);logStartupProfileInfo(context);}// Add boot specific singleton beansConfigurableListableBeanFactory beanFactory = context.getBeanFactory();beanFactory.registerSingleton("springApplicationArguments", applicationArguments);if (printedBanner != null) {beanFactory.registerSingleton("springBootBanner", printedBanner);}if (beanFactory instanceof DefaultListableBeanFactory) {((DefaultListableBeanFactory) beanFactory).setAllowBeanDefinitionOverriding(this.allowBeanDefinitionOverriding);}if (this.lazyInitialization) {context.addBeanFactoryPostProcessor(new LazyInitializationBeanFactoryPostProcessor());}// Load the sourcesSet<Object> sources = getAllSources();Assert.notEmpty(sources, "Sources must not be empty");load(context, sources.toArray(new Object[0]));listeners.contextLoaded(context);}----------------// org.springframework.boot.SpringApplication#applyInitializersprotected void applyInitializers(ConfigurableApplicationContext context) {for (ApplicationContextInitializer initializer : getInitializers()) {Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(),ApplicationContextInitializer.class);Assert.isInstanceOf(requiredType, context, "Unable to call initializer.");// 循环执行其方法,这也不出意外// 外部集成实现的Initializer 多是 这这里注册 ApplicationListener 有意思吧// 也算是一种"另类的" 注册 ApplicationListener 的方式initializer.initialize(context);}}

2. ApplicationListener

spring的事件传播机制,其实很简单
请添加图片描述

2.1 AbstractEventMulticaster

索性把相关类都给枚举一下
请添加图片描述

2.2 事件传播轨迹

	// org.springframework.context.event.SimpleApplicationEventMulticaster#multicastEvent(org.springframework.context.ApplicationEvent)@Overridepublic void multicastEvent(ApplicationEvent event) {// step into ...multicastEvent(event, resolveDefaultEventType(event));}@Overridepublic void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));Executor executor = getTaskExecutor();for (ApplicationListener<?> listener : getApplicationListeners(event, type)) {// 支持线程池中调用if (executor != null) {executor.execute(() -> invokeListener(listener, event));}else {invokeListener(listener, event);}}}/*** Invoke the given listener with the given event.* @param listener the ApplicationListener to invoke* @param event the current event to propagate* @since 4.1*/protected void invokeListener(ApplicationListener<?> listener, ApplicationEvent event) {ErrorHandler errorHandler = getErrorHandler();if (errorHandler != null) {try {// step into ...doInvokeListener(listener, event);}catch (Throwable err) {errorHandler.handleError(err);}}else {doInvokeListener(listener, event);}}// org.springframework.context.event.SimpleApplicationEventMulticaster#doInvokeListenerprivate void doInvokeListener(ApplicationListener listener, ApplicationEvent event) {try {// ApplicationListener.onApplicationEvent()listener.onApplicationEvent(event);}catch (ClassCastException ex) {String msg = ex.getMessage();if (msg == null || matchesClassCastMessage(msg, event.getClass())) {// Possibly a lambda-defined listener which we could not resolve the generic event type for// -> let's suppress the exception and just log a debug message.Log logger = LogFactory.getLog(getClass());if (logger.isTraceEnabled()) {logger.trace("Non-matching event type for listener: " + listener, ex);}}else {throw ex;}}}

3. SpringApplicationRunListeners

  • 提供了多个生命周期的回调方法
  • 内部维护了多个 SpringApplicationRunListener
  • SpringApplicationRunListener会在各个生命周期中调用 Multicaster 传播事件(回调监听器的方法)
    请添加图片描述

3.1 注册

	// org.springframework.boot.SpringApplication#run(java.lang.String...)public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();configureHeadlessProperty();// step into ...SpringApplicationRunListeners listeners = getRunListeners(args);listeners.starting();try {ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);Banner printedBanner = printBanner(environment);context = createApplicationContext();// step into SpringBootExceptionReporter.java ...//  顺带说一下,ExceptionReporters 也是滴exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);prepareContext(context, environment, listeners, applicationArguments, printedBanner);refreshContext(context);afterRefresh(context, applicationArguments);stopWatch.stop();if (this.logStartupInfo) {new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);}listeners.started(context);callRunners(context, applicationArguments);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, listeners);throw new IllegalStateException(ex);}try {listeners.running(context);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, null);throw new IllegalStateException(ex);}return context;}-------------------------// org.springframework.boot.SpringApplication#getRunListenersprivate SpringApplicationRunListeners getRunListeners(String[] args) {Class<?>[] types = new Class<?>[] { SpringApplication.class, String[].class };// step into ...// 不如,看看 RunListeners 的内部结构表return new SpringApplicationRunListeners(logger,// 这里逻辑重复,就不step into 了getSpringFactoriesInstances(SpringApplicationRunListener.class, types, this, args));}---------------------// spring.boot 才有的
package org.springframework.boot;class SpringApplicationRunListeners {// step into ...private final List<SpringApplicationRunListener> listeners;SpringApplicationRunListeners(Log log, Collection<? extends SpringApplicationRunListener> listeners) {this.log = log;this.listeners = new ArrayList<>(listeners);}// 下面的方法都是大差不差的: 在各个声明周期中,调用,循环执行 runListener 对应的钩子方法void starting() {for (SpringApplicationRunListener listener : this.listeners) {listener.starting();}}void environmentPrepared(ConfigurableEnvironment environment) {for (SpringApplicationRunListener listener : this.listeners) {listener.environmentPrepared(environment);}}void contextPrepared(ConfigurableApplicationContext context) {for (SpringApplicationRunListener listener : this.listeners) {listener.contextPrepared(context);}}void contextLoaded(ConfigurableApplicationContext context) {for (SpringApplicationRunListener listener : this.listeners) {listener.contextLoaded(context);}}void started(ConfigurableApplicationContext context) {for (SpringApplicationRunListener listener : this.listeners) {listener.started(context);}}void running(ConfigurableApplicationContext context) {for (SpringApplicationRunListener listener : this.listeners) {listener.running(context);}}void failed(ConfigurableApplicationContext context, Throwable exception) {for (SpringApplicationRunListener listener : this.listeners) {callFailedListener(listener, context, exception);}}private void callFailedListener(SpringApplicationRunListener listener, ConfigurableApplicationContext context,Throwable exception) {try {listener.failed(context, exception);}catch (Throwable ex) {if (exception == null) {ReflectionUtils.rethrowRuntimeException(ex);}if (this.log.isDebugEnabled()) {this.log.error("Error handling failed", ex);}else {String message = ex.getMessage();message = (message != null) ? message : "no error message";this.log.warn("Error handling failed (" + message + ")");}}}}------------------package org.springframework.boot.context.event;// SpringApplicationRunListener 暂时只有这个实现类
public class EventPublishingRunListener implements SpringApplicationRunListener, Ordered {private final SpringApplication application;private final String[] args;// 懂了// RunListener 监听到 springApplication 的某一生命周期时,借助这个广播事件,给ApplicationListenersprivate final SimpleApplicationEventMulticaster initialMulticaster;public EventPublishingRunListener(SpringApplication application, String[] args) {this.application = application;this.args = args;// 事件广播器 也是构造的时候,顺带初始化的!!!this.initialMulticaster = new SimpleApplicationEventMulticaster();for (ApplicationListener<?> listener : application.getListeners()) {this.initialMulticaster.addApplicationListener(listener);}}@Overridepublic int getOrder() {return 0;}@Overridepublic void starting() {this.initialMulticaster.multicastEvent(new ApplicationStartingEvent(this.application, this.args));}@Overridepublic void environmentPrepared(ConfigurableEnvironment environment) {this.initialMulticaster.multicastEvent(new ApplicationEnvironmentPreparedEvent(this.application, this.args, environment));}@Overridepublic void contextPrepared(ConfigurableApplicationContext context) {this.initialMulticaster.multicastEvent(new ApplicationContextInitializedEvent(this.application, this.args, context));}@Overridepublic void contextLoaded(ConfigurableApplicationContext context) {for (ApplicationListener<?> listener : this.application.getListeners()) {if (listener instanceof ApplicationContextAware) {((ApplicationContextAware) listener).setApplicationContext(context);}context.addApplicationListener(listener);}this.initialMulticaster.multicastEvent(new ApplicationPreparedEvent(this.application, this.args, context));}@Overridepublic void started(ConfigurableApplicationContext context) {context.publishEvent(new ApplicationStartedEvent(this.application, this.args, context));AvailabilityChangeEvent.publish(context, LivenessState.CORRECT);}@Overridepublic void running(ConfigurableApplicationContext context) {context.publishEvent(new ApplicationReadyEvent(this.application, this.args, context));AvailabilityChangeEvent.publish(context, ReadinessState.ACCEPTING_TRAFFIC);}@Overridepublic void failed(ConfigurableApplicationContext context, Throwable exception) {ApplicationFailedEvent event = new ApplicationFailedEvent(this.application, this.args, context, exception);if (context != null && context.isActive()) {// Listeners have been registered to the application context so we should// use it at this point if we cancontext.publishEvent(event);}else {// An inactive context may not have a multicaster so we use our multicaster to// call all of the context's listeners insteadif (context instanceof AbstractApplicationContext) {for (ApplicationListener<?> listener : ((AbstractApplicationContext) context).getApplicationListeners()) {this.initialMulticaster.addApplicationListener(listener);}}this.initialMulticaster.setErrorHandler(new LoggingErrorHandler());this.initialMulticaster.multicastEvent(event);}}private static class LoggingErrorHandler implements ErrorHandler {private static final Log logger = LogFactory.getLog(EventPublishingRunListener.class);@Overridepublic void handleError(Throwable throwable) {logger.warn("Error calling ApplicationEventListener", throwable);}}}

Multicaster 与 ApplicationListener、 RunListener、RunListeners的关系
请添加图片描述

4. SpringBootExceptionReporter

同上,也是 spring.boot 特有的
请添加图片描述

4.1 应用

// spring.boot 的
package org.springframework.boot.diagnostics;/*** Utility to trigger {@link FailureAnalyzer} and {@link FailureAnalysisReporter}* instances loaded from {@code spring.factories}.* <p>* A {@code FailureAnalyzer} that requires access to the {@link BeanFactory} in order to* perform its analysis can implement {@code BeanFactoryAware} to have the* {@code BeanFactory} injected prior to {@link FailureAnalyzer#analyze(Throwable)} being* called.** @author Andy Wilkinson* @author Phillip Webb* @author Stephane Nicoll*/
// SpringBootExceptionReporter 暂时仅有这个实现类
final class FailureAnalyzers implements SpringBootExceptionReporter {// step into ..// 逻辑在这里,目前还不知道干嘛的private final List<FailureAnalyzer> analyzers;FailureAnalyzers(ConfigurableApplicationContext context) {this(context, null);}FailureAnalyzers(ConfigurableApplicationContext context, ClassLoader classLoader) {Assert.notNull(context, "Context must not be null");this.classLoader = (classLoader != null) ? classLoader : context.getClassLoader();this.analyzers = loadFailureAnalyzers(this.classLoader);prepareFailureAnalyzers(this.analyzers, context);}private List<FailureAnalyzer> loadFailureAnalyzers(ClassLoader classLoader) {List<String> analyzerNames = SpringFactoriesLoader.loadFactoryNames(FailureAnalyzer.class, classLoader);List<FailureAnalyzer> analyzers = new ArrayList<>();for (String analyzerName : analyzerNames) {try {Constructor<?> constructor = ClassUtils.forName(analyzerName, classLoader).getDeclaredConstructor();ReflectionUtils.makeAccessible(constructor);analyzers.add((FailureAnalyzer) constructor.newInstance());}catch (Throwable ex) {logger.trace(LogMessage.format("Failed to load %s", analyzerName), ex);}}AnnotationAwareOrderComparator.sort(analyzers);return analyzers;}private void prepareFailureAnalyzers(List<FailureAnalyzer> analyzers, ConfigurableApplicationContext context) {for (FailureAnalyzer analyzer : analyzers) {prepareAnalyzer(context, analyzer);}}private void prepareAnalyzer(ConfigurableApplicationContext context, FailureAnalyzer analyzer) {if (analyzer instanceof BeanFactoryAware) {((BeanFactoryAware) analyzer).setBeanFactory(context.getBeanFactory());}if (analyzer instanceof EnvironmentAware) {((EnvironmentAware) analyzer).setEnvironment(context.getEnvironment());}}@Overridepublic boolean reportException(Throwable failure) {FailureAnalysis analysis = analyze(failure, this.analyzers);return report(analysis, this.classLoader);}private FailureAnalysis analyze(Throwable failure, List<FailureAnalyzer> analyzers) {for (FailureAnalyzer analyzer : analyzers) {try {FailureAnalysis analysis = analyzer.analyze(failure);if (analysis != null) {return analysis;}}catch (Throwable ex) {logger.debug(LogMessage.format("FailureAnalyzer %s failed", analyzer), ex);}}return null;}private boolean report(FailureAnalysis analysis, ClassLoader classLoader) {List<FailureAnalysisReporter> reporters = SpringFactoriesLoader.loadFactories(FailureAnalysisReporter.class,classLoader);if (analysis == null || reporters.isEmpty()) {return false;}for (FailureAnalysisReporter reporter : reporters) {reporter.report(analysis);}return true;}}------------package org.springframework.boot.diagnostics;// 这个实现类也忒多
/*** A {@code FailureAnalyzer} is used to analyze a failure and provide diagnostic* information that can be displayed to the user.* 渣翻: 用来解析失败,并且以某种形式反馈给用户** @author Andy Wilkinson* @since 1.4.0*/
@FunctionalInterface
public interface FailureAnalyzer {/*** Returns an analysis of the given {@code failure}, or {@code null} if no analysis* was possible.* @param failure the failure* @return the analysis or {@code null}*/FailureAnalysis analyze(Throwable failure);}

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

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

相关文章

允许Traceroute探测漏洞和ICMP timestamp请求响应漏洞解决方法

目录 服务器检测出了漏洞需要修改 1.允许Traceroute探测漏洞解决方法 2、ICMP timestamp请求响应漏洞 服务器检测出了漏洞需要修改 1.允许Traceroute探测漏洞解决方法 详细描述 本插件使用Traceroute探测来获取扫描器与远程主机之间的路由信息。攻击者也可以利用这些信息来…

开源项目推荐 【SkyEyeSystem】

大家好&#xff0c;今天向大家推荐一个开源项目——SkyEyeSystem。 这是一个基于Spring Boot的全网热点爬虫项目&#xff0c;旨在提供全面而准确的全网热搜数据。 关于项目 SkyEyeSystem通过定时任务间隔10min爬取全网热搜数据。目前包括的平台有&#xff1a; 微博热搜B站热…

sklearn.model_selection模块介绍

数据集划分方法 train_test_split train_test_split(*arrays, test_sizeNone, train_sizeNone, random_stateNone, shuffleTrue, stratifyNone)参数包括&#xff1a; test_size&#xff1a;可选参数&#xff0c;表示测试集的大小。可以是一个表示比例的浮点数&#xff08;例…

经典基于外观的SLAM框架-RTABMAP(RGBD视觉输入方案)

经典基于外观的SLAM框架-RTABMAP 文章目录 经典基于外观的SLAM框架-RTABMAP1. RTABMAP整体框架2.RTABMAP的内存管理机制3. 视觉里程计4. 局部地图5. 回环检测与图优化6. 代码工程实践 1. RTABMAP整体框架 RTABMAP是采用优化算法的方式求解SLAM问题的SLAM框架&#xff0c;本赛题…

C#异常总结

C#异常总结 定义Try语句异常类创建用户自定义异常搜索调用栈的示例异常抛出 定义 程序中的运行时错误&#xff0c;它违反一个系统约束或应用程序约束&#xff0c;或出现了在正常操作时未预料的情形。 Try语句 指明被异常保护的代码块&#xff0c;并提供代码以处理异常。try由…

【机器学习】支持向量机(下)

支持向量机&#xff08;下&#xff09; 目录 八、支持向量机的求解实例九、核函数1、核函数的引入2、核函数的示例 十、软间隔1、何为软间隔2、引入软间隔后的目标方程 十一、正则化十二、关于支持向量机的分类十三、数据标准化的影响【机器学习】支持向量机&#xff08;上&…

Segment Anything:突破边界的图像分割新技术解析

Segment Anything论文地址&#xff1a;https://arxiv.org/pdf/2304.02643.pdf Segment Anything&#xff1a;突破边界的图像分割新技术解析 论文背景Segment Anything任务方法Segment Anything 模型架构图像编码器&#xff08;Image Encoder&#xff09;提示编码器&#xff08;…

Java JSP实战

综合实战&#xff1a; 实现利用servletservicedao实现查询所有&#xff0c;对象&#xff0c;增删改&#xff0c; t_house(int no,String housename,Double height) 步骤1&#xff1a;创建maven工程 步骤2&#xff1a;创建工程包entity,dao,util,service,servlet 步骤3&#x…

接口抓包分析与Mock实战

这里写目录标题 一、知识点梳理1、接口抓包需要具备的能力2、接口抓包原理 二、Charles 基础使用三、charles抓包分析四、Charles 使用1、过滤&#xff1a;Filter、Focus2、重发&#xff1a;Repeat、Repeat Advanced3、修改请求&#xff1a;Compose4、弱网&#xff1a;Throttle…

npm包管理器

一、什么是npm Npm&#xff08;Node Package Manager&#xff09;是一个用于管理和共享JavaScript代码包的包管理器。它是Node.js的默认包管理工具&#xff0c;也是世界上最大的软件注册表之一。下面从不同的角度来详细介绍Npm包管理器。 1. 功能与用途&#xff1a; 包安装与…

FPGA USB FX2 图片发送试验 驱动CY7C68013A实现 提供2套工程源码和技术支持

目录 1、前言2、我这儿已有的 FPGA USB 通信方案3、CY7C68013A芯片解读和硬件设计FX2 简介SlaveFIFO模式及其配置 4、工程详细设计方案输入测试图片的处理PC上位机发送测试图片图像接收与缓存图像输出显示 5、vivado工程1--LCD输出显示6、vivado工程1--LCD输出显示7、上板调试验…