一个spring boot项目的启动过程分析
1、web.xml 定义入口类
<context-param><param-name>contextConfigLocation</param-name><param-value>com.baosight.ApplicationBoot</param-value>
</context-param>
2、主入口类: ApplicationBoot,SpringBoot项目的mian函数
@SpringBootApplication(scanBasePackages = "com.bs")
@ServletComponentScan("com.bs.4j.core.web.servlet")
@ImportResource(locations = {"classpath*:spring/framework/platApplicationContext*.xml", "classpath*:spring/framework/applicationContext*.xml"})
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class})
public class ApplicationBoot extends SpringBootServletInitializer {public static void main(String[] args) {SpringApplication app = new SpringApplication(ApplicationBoot.class);app.run(args);}@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {return application.sources(ApplicationBoot.class);}}
3、SpringApplication
SpringApplication
类是Spring Boot框架的核心组件之一,它负责整个应用的启动和初始化过程。SpringApplication
的设计目标是简化Spring应用的启动步骤,提供一套开箱即用的配置,让开发者能够快速启动和运行Spring应用。
在这个类中:
3.1、SpringApplication构造方法
/*** Create a new {@link SpringApplication} instance. The application context will load* beans from the specified primary sources (see {@link SpringApplication class-level}* documentation for details. The instance can be customized before calling* {@link #run(String...)}.* @param primarySources the primary bean sources* @see #run(Class, String[])* @see #SpringApplication(ResourceLoader, Class...)* @see #setSources(Set)*/public SpringApplication(Class<?>... primarySources) {this(null, primarySources);}/*** Create a new {@link SpringApplication} instance. The application context will load* beans from the specified primary sources (see {@link SpringApplication class-level}* documentation for details. The instance can be customized before calling* {@link #run(String...)}.* @param resourceLoader the resource loader to use* @param primarySources the primary bean sources* @see #run(Class, String[])* @see #setSources(Set)*/@SuppressWarnings({ "unchecked", "rawtypes" })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();setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));this.mainApplicationClass = deduceMainApplicationClass();}
对于构造函数的解读
-
参数初始化:
resourceLoader
:这是一个资源加载器,用于从类路径或其他位置加载资源,如配置文件、静态资源等。primarySources
:这是应用程序的主要配置源,通常是一个或多个配置类的数组,用于引导Spring的自动配置和组件扫描。
-
非空检查:
- 对
primarySources
进行非空检查,确保至少有一个配置源被提供,否则将抛出IllegalArgumentException
。
- 对
-
配置源存储:
- 将
primarySources
转换为LinkedHashSet
集合并存储,保持插入顺序,这有助于后续的配置解析和组件扫描。
- 将
-
Web应用类型推断:
- 调用
WebApplicationType.deduceFromClasspath()
方法自动检测应用的Web类型,是Servlet-based、Reactive-based还是None(非Web应用)。这一决策影响了Spring Boot如何初始化Web环境。
- 调用
-
ApplicationContext Initializers设置:
- 调用
getSpringFactoriesInstances
方法来获取所有实现了ApplicationContextInitializer
接口的实例,并将其设置为SpringApplication
的initializers。这些initializers会在ApplicationContext
创建过程中被调用,用于自定义上下文的初始化。
- 调用
-
Application Listeners设置:
- 同样地,通过
getSpringFactoriesInstances
方法获取所有实现了ApplicationListener
接口的实例,并将其设置为SpringApplication
的listeners。这些listeners会在应用生命周期的不同阶段被触发,如启动、停止等。
- 同样地,通过
-
主应用类推断:
- 调用
deduceMainApplicationClass
方法来确定应用的主类,通常是启动应用的那个类,用于在某些情况下(如生成文档)标识应用本身。
- 调用
3.1.1、WebApplicationType.deduceFromClasspath()
检测应用的Web类型,在下文
ConfigurableApplicationContext的实例化中会使用到
3.1.2、setInitializers
初始化classpath下 META-INF/spring.factories中已配置的ApplicationContextInitializer
private <T> Collection<T> getSpringFactoriesInstances(Class<T> type) {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、getSpringFactoriesInstances有什么用,做了什么,这个方法是根据给定的类型type
和ClassLoader
,从spring-core提供的FACTORIES_RESOURCE_LOCATION=META-INF/spring.factories文件中加载所有该类型的工厂类名,即获取指定的类(key)的同一入口方法。这里使用了LinkedHashSet
来存储这些名字,确保它们是唯一的且按插入顺序排序。这一块在SpringFactoriesLoader.loadFactoryNames/loadSpringFactories中实现
public static List<String> loadFactoryNames(Class<?> factoryClass, @Nullable ClassLoader classLoader) {String factoryClassName = factoryClass.getName();return loadSpringFactories(classLoader).getOrDefault(factoryClassName, Collections.emptyList());}private static Map<String, List<String>> loadSpringFactories(@Nullable ClassLoader classLoader) {MultiValueMap<String, String> result = cache.get(classLoader);if (result != null) {return result;}try {Enumeration<URL> urls = (classLoader != null ?classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));result = new LinkedMultiValueMap<>();while (urls.hasMoreElements()) {URL url = urls.nextElement();UrlResource resource = new UrlResource(url);Properties properties = PropertiesLoaderUtils.loadProperties(resource);for (Map.Entry<?, ?> entry : properties.entrySet()) {String factoryClassName = ((String) entry.getKey()).trim();for (String factoryName : StringUtils.commaDelimitedListToStringArray((String) entry.getValue())) {result.add(factoryClassName, factoryName.trim());}}}cache.put(classLoader, result);return result;}catch (IOException ex) {throw new IllegalArgumentException("Unable to load factories from location [" +FACTORIES_RESOURCE_LOCATION + "]", ex);}}
在这里,获取的是key为 org.springframework.context.ApplicationContextInitializer 的类。ApplicationContextInitializer 是Spring框架的类, 这个类的主要目的就是在 ConfigurableApplicationContext 调用refresh()方法之前,回调这个类的initialize方法。通过 ConfigurableApplicationContext 的实例获取容器的环境Environment,从而实现对配置文件的修改完善等工作。
3.1.3 、setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
ApplicationListener 的加载过程和上面的 ApplicationContextInitializer 类的加载过程是一样的.ApplicationListener 是spring的事件监听器,典型的观察者模式,通过 ApplicationEvent 类和 ApplicationListener 接口,可以实现对spring容器全生命周期的监听
SpringApplication 类的实例化过程,我们可以在spring容器创建之前做一些预备工作,和定制化的需求。比如,自定义SpringBoot的Banner,比如自定义事件监听器,再比如在容器refresh之前通过自定义 ApplicationContextInitializer 修改配置一些配置或者获取指定的bean都是可以的
3.2、SpringApplication.run()
如下面代码所示
/*** Run the Spring application, creating and refreshing a new* {@link ApplicationContext}.* @param args the application arguments (usually passed from a Java main method)* @return a running {@link ApplicationContext}*/
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);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;
}
run方法详解:
-
计时和异常处理设置:
-
创建一个
StopWatch
对象来测量应用启动所需的时间。 -
初始化一个空列表
exceptionReporters
,用于存放异常报告器。
-
-
配置无头模式:
-
调用
configureHeadlessProperty
方法确保应用在没有图形界面的环境中也能运行。
-
-
监听器初始化:
-
获取
SpringApplicationRunListeners
监听器实例,并调用starting
方法通知监听器应用即将开始启动。
-
-
解析命令行参数:
-
创建
ApplicationArguments
实例,用于解析传入的命令行参数。
-
-
环境准备:
-
准备
ConfigurableEnvironment
环境,这个环境包含了应用的配置信息。应用上下文环境包括什么呢?包括计算机的环境,Java环境,Spring的运行环境,Spring项目的配置(在SpringBoot中就是那个熟悉的application.properties/yml)等等。
-
-
忽略Bean信息配置:
-
调用
configureIgnoreBeanInfo
方法,这通常用于性能优化,避免加载不必要的Bean信息。
-
-
打印Banner:
-
打印应用的启动Banner,显示应用名、版本等信息。
-
-
创建ApplicationContext:
-
创建
ConfigurableApplicationContext
上下文,这是Spring管理Bean的容器。
-
-
异常报告器获取:
-
通过
getSpringFactoriesInstances
方法获取所有SpringBootExceptionReporter
实例。
-
-
上下文准备:
-
调用
prepareContext
方法进行上下文的准备工作,包括注册Bean后处理器、监听器等。
-
-
刷新上下文:
-
调用
refreshContext
方法刷新上下文,这是Spring Bean生命周期的关键点。
-
-
启动后操作:
-
调用
afterRefresh
方法执行一些应用启动后的操作,如初始化定时任务等。
-
-
日志记录:
-
如果配置了记录启动信息,使用
StartupInfoLogger
记录应用启动完成的日志。
-
-
监听器回调:
-
通知监听器应用已经启动。
-
-
运行Runners:
-
调用
callRunners
方法执行定义好的ApplicationRunner
或CommandLineRunner
,它们通常用于执行一些启动后的初始化工作。
-
-
异常处理:
-
在整个启动过程中捕获并处理可能发生的异常,确保应用能够优雅地处理错误。
-
-
返回ApplicationContext:
-
最终返回创建的
ConfigurableApplicationContext
实例,这是Spring Boot应用的核心组件。
-
3.3、ConfigurableApplicationContext
ConfigurableApplicationContext
是Spring框架中ApplicationContext
接口的一个扩展,它提供了更多的配置和控制能力,是Spring应用程序上下文的高级接口。在Spring Boot中,ConfigurableApplicationContext
扮演着核心角色,用于管理应用程序的生命周期和Bean的配置。下面是一些关键特性及其作用的详细解读:
配置和定制
ConfigurableApplicationContext
允许开发者在应用程序启动时对上下文进行更深入的定制,例如设置Environment
、ResourceLoader
、MessageSource
、ApplicationEventPublisher
等。这使得你可以更灵活地调整Spring容器的行为,以适应不同的应用场景。
刷新上下文
与ApplicationContext
不同的是,ConfigurableApplicationContext
提供了refresh()
方法,用于手动刷新上下文,重新加载配置并初始化Bean。这是非常有用的,特别是在测试场景中,你需要在每次测试之前重置Spring上下文的状态。
关闭上下文
ConfigurableApplicationContext
提供了close()
方法,允许你优雅地关闭上下文,释放资源。这对于那些不需要一直运行的应用程序尤其重要,比如批处理作业或命令行应用。
监听器支持
它支持ApplicationListener
,允许你在上下文的生命周期事件(如启动、关闭、Bean实例化等)中注册监听器,以便于执行自定义逻辑。这对于集成日志记录、健康检查等功能非常有用。
环境感知
ConfigurableApplicationContext
允许你访问和修改应用的Environment
,这包括读取和设置配置属性、切换不同的配置文件(profiles)等。这对于多环境部署(如开发、测试、生产)的管理至关重要。
事件发布
除了标准的ApplicationEventPublisher
功能,ConfigurableApplicationContext
还提供了更细粒度的事件发布和监听机制,这对于实现复杂的业务逻辑和系统集成非常有帮助。
实例化
在Spring Boot中,SpringApplication
的run
方法通过createApplicationContext返回一个ConfigurableApplicationContext
实例,这通常是应用程序的主要入口点,可以通过这个上下文访问到所有由Spring管理的Bean和资源。下面则是createApplicationContext的具体实现:
Strategy method used to create the ApplicationContext. By default this method will respect any explicitly set application context or application context class before falling back to a suitable default.
返回值:
the application context (not yet refreshed)
请参阅:
setApplicationContextClass(Class)
protected ConfigurableApplicationContext createApplicationContext() {Class<?> contextClass = this.applicationContextClass;if (contextClass == null) {try {switch (this.webApplicationType) {case SERVLET:contextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS);break;case REACTIVE:contextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS);break;default:contextClass = Class.forName(DEFAULT_CONTEXT_CLASS);}}catch (ClassNotFoundException ex) {throw new IllegalStateException("Unable create a default ApplicationContext, "+ "please specify an ApplicationContextClass",ex);}}return (ConfigurableApplicationContext) BeanUtils.instantiateClass(contextClass);}
3.2.1、WebApplicationType详解
WebApplicationType,一个枚举,且里面定义了三个枚举值,分别是 NONE、SERVLET、REACTIVE
SERVLET:传统的Servlet-based web应用,内嵌基于 servlet 的 web 服务器(如:Tomcat,Jetty,Undertow 等,其实现在大多Java网站应用都是采用的基于 Tomcat 的 servlet 类型服务器),默认使用AnnotationConfigServletWebServerApplicationContext
作为上下文。
REACTIVE:响应式web应用,在 servlet 容器当中,采用命令式编程方式,代码一句一句的执行,这样更有利于理解与调试,而在反应式的 web 编程中,是基于异步响应式,现在 WebFlux 框架就是一个较为流行的反应式编程,默认使用AnnotationConfigReactiveWebServerApplicationContext
作为上下文。
NONE:既不是SERVLET
也不是REACTIVE:
即非Web应用,非 web 应用程序(不内嵌服务器),则默认使用AnnotationConfigApplicationContext
作为上下文。
而关于Springboot 如何确定程序的应用类型 WebApplicationType 的?
在SpringApplication构造方法:
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();setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));this.mainApplicationClass = deduceMainApplicationClass();}
this.webApplicationType = WebApplicationType.deduceFromClasspath();其中 WebApplicationType.deduceFromClasspath() 这个方法实现如下
static WebApplicationType deduceFromClasspath() {if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null)&& !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null)&& !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) {return WebApplicationType.REACTIVE;}for (String className : SERVLET_INDICATOR_CLASSES) {if (!ClassUtils.isPresent(className, null)) {return WebApplicationType.NONE;}}return WebApplicationType.SERVLET;}
ClassUtils.isPresent()?干什么的?用来判断一个类的存在性的,当这个类存在,那么返回的就是 true;当这个类不存在时,返回的结果就是 fasle。
(1)WEBFLUX_INDICATOR_CLASS,WEBMVC_INDICATOR_CLASS,JERSEY_INDICATOR_CLASS常量值又分别是什么?看源码
private static final String WEBMVC_INDICATOR_CLASS = "org.springframework."+ "web.servlet.DispatcherServlet";private static final String WEBFLUX_INDICATOR_CLASS = "org."+ "springframework.web.reactive.DispatcherHandler";private static final String JERSEY_INDICATOR_CLASS = "org.glassfish.jersey.servlet.ServletContainer";
当项目中存在 DispatcherHandler 这个类,且不存在 DispatcherServlet 类和ServletContainer时,程序的应用类型就是 REACTIVE,也就是他会加载嵌入一个反应式的 web 服务器。
(2)而SERVLET_INDICATOR_CLASSES
private static final String[] SERVLET_INDICATOR_CLASSES = { "javax.servlet.Servlet","org.springframework.web.context.ConfigurableWebApplicationContext" };
当项目中 Servlet 和 ConfigurableWebApplicationContext 其中一个不存在时,则程序的应用类型为 NONE,它并不会加载内嵌任何 web 服务器。
(3)除了上面两种情况外,其余的都按 SERVLET 类型处理,会内嵌一个 servlet 类型的 web 服务器
上面的这些类的判定,都来源于 Spring 的相关依赖包,而这依赖包是否需要导入,也是开发者所决定的,所以说开发者可以决定程序的应用类型,并不是 Srpingboot 本身决定的。
3.4、refreshContext
相关文章:

一个spring boot项目的启动过程分析
1、web.xml 定义入口类 <context-param><param-name>contextConfigLocation</param-name><param-value>com.baosight.ApplicationBoot</param-value> </context-param> 2、主入口类: ApplicationBoot,SpringBoot项目的mian函数 SpringBo…...

智驭未来:人工智能与目标检测的深度交融
在科技日新月异的今天,人工智能(AI)如同一股不可阻挡的浪潮,正以前所未有的速度重塑着我们的世界。在众多AI应用领域中,目标检测以其独特的魅力和广泛的应用前景,成为了连接现实与智能世界的桥梁。本文旨在…...

01MFC建立单个文件类型——画线
文章目录 选择模式初始化文件作用解析各初始化文件解析 类导向创建鼠标按键按下抬起操作函数添加一个变量记录起始位置注意事项代码实现效果图 虚实/颜色线 选择模式 初始化文件作用解析 运行: 各初始化文件解析 MFC(Microsoft Foundation Classes&am…...

免杀中用到的工具
🟢 绝大部分无法直接生成免杀木马,开发、测试免杀时会用到。 工具简称 概述 工具来源 下载路径 x64dbg 中文版安装程序(Jan 6 2024).exe 52pojie hellshell 官方的加密或混淆shellcode github Releases ORCA / HellShell GitLab hellshe…...

[vite] Pre-transform error: Cannot find package pnpm路径过长导致运行报错
下了套vue3的代码,执行pnpm install初始化,使用vite启动,启动后访问就会报错 报错信息 ERROR 16:40:53 [vite] Pre-transform error: Cannot find package E:\work\VSCodeProjectWork\jeecg\xxxxxxxxx-next\xxxxxxxxx-next-jeecgBoot-vue3\…...

Promise总结
Promise.then() 的返回值仍然是 Promise 对象 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8" /><meta name"viewport" content"widthdevice-width, initial-scale1.0" /><title>D…...

ROI 接口便捷修改
传入的图片截取ROI后再进入识别接口 (识别接口比ROI接口的函数参数少一个传入的ROI) 无点只有点集 返回双点集 //平直冷侧翅片 bool ImageProcessingTest::straightColdSideFin_ROI(cv::Mat img, cv::Rect ROI, std::vector<cv::Point>& topL…...

jenkins打包java项目报错Error: Unable to access jarfile tlm-admin.jar
jenkins打包boot项目 自动重启脚本失败 查看了一下项目日志报错: Error: Unable to access jarfile tlm-admin.jar我检查了一下这个配置,感觉没有问题,包可以正常打, cd 到项目目录下面,手动执行这个sh脚本也是能正常…...

SQL Server设置端口:跨平台指南
在使用SQL Server时,设置或修改其监听的端口是确保数据库服务安全访问和高效管理的重要步骤。由于SQL Server可以部署在多种操作系统上,包括Windows、Linux和Docker容器等,因此设置端口的步骤和方法也会因平台而异。本文将为您提供一个跨平台…...

ActiveMQ-CVE-2023-46604
Apache ActiveMQ OpenWire 协议反序列化命令执行漏洞 OpenWire协议在ActiveMQ中被用于多语言客户端与服务端通信。在Apache ActvieMQ5.18.2版本以及以前,OpenWire协议通信过程中存在一处反序列化漏洞,该漏洞可以允许具有网络访问权限的远程攻击者通过操作…...

TensorBoard ,PIL 和 OpenCV 在深度学习中的应用
重要工具介绍 TensorBoard: 是一个TensorFlow提供的强大工具,用于可视化和理解深度学习模型的训练过程和结果。下面我将介绍TensorBoard的相关知识和使用方法。 TensorBoard 简介 TensorBoard是TensorFlow提供的一个可视化工具,用于&#x…...

【超音速 专利 CN117576413A】基于全连接网络分类模型的AI涂布抓边处理方法及系统
申请号CN202311568976.4公开号(公开)CN117576413A申请日2023.11.22申请人(公开)超音速人工智能科技股份有限公司发明人(公开)张俊峰(总); 杨培文(总); 沈俊羽…...

iPhone数据恢复篇:iPhone 数据恢复软件有哪些
问题:iPhone 15 最好的免费恢复软件是什么?我一直在寻找一个恢复程序来恢复从iPhone中意外删除的照片,联系人和消息,但是我有很多选择。 谷歌一下,你会发现许多付费或免费的iPhone数据恢复工具,声称它们可…...

Html5+Css3学习笔记
Html5 CSS3 一、概念 1.什么是html5 html: Hyper Text Markup Language ( 超文本标记语言) 文本:记事本 超文本: 文字、图片、音频、视频、动画等等(网页) html语言经过浏览器的编译显示成超文本 开发者使用5种浏览器…...

WPF学习(2) -- 样式基础
一、代码 <Window x:Class"学习.MainWindow"xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x"http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d"http://schemas.microsoft.com/expression/blend/2008&…...

独家揭秘!五大内网穿透神器,访问你的私有服务
本文精心筛选了五款炙手可热的内网穿透工具,它们各怀绝技,无论您是企业用户、独立开发者,还是技术探索者,这篇文章都物有所值,废话不多说,主角们即将上场。 目录 1. 巴比达 - 安全至上的企业护航者 2. 花…...

Ubuntu 编译和运行ZLMediaKit
摘要 本文描述了如何在Ubuntu上构建ZLMediaKIt项目源码,以及如何体验其WebRTC推流和播放功能。 实验环境 操作系统版本:Ubuntu 22.04.3 LTS gcc版本:11.4.0 g版本:11.4.0 依赖库安装 #让ZLMediaKit媒体服务器具备WebRTC流转发…...

基于JavaSpringBoot+Vue+uniapp微信小程序校园宿舍管理系统设计与实现
基于JavaSpringBootVueuniapp微信小程序实现校园宿舍管理系统设计与实现 目录 第一章 绪论 1.1 研究背景 1.2 研究现状 1.3 研究内容 第二章 相关技术介绍 2.1 Java语言 2.2 HTML网页技术 2.3 MySQL数据库 2.4 Springboot 框架介绍 2.5 VueJS介绍 2.6 ElementUI介绍…...

Hive的基本操作(创建与修改)
必备知识 数据类型 基本类型 类型写法字符char, varchar, string✔整数tinyint, smallint, int✔, bigint✔小数float, double, numeric(m,n), decimal(m,n)✔布尔值boolean✔时间date✔, timestamp✔ 复杂类型(集合类型) 1、数组:array<T> 面向用户提供…...

Linux开发讲课37--- ARM的22个常用概念
1. ARM中一些常见英文缩写解释 MSB:最高有效位; LSB:最低有效位; AHB:先进的高性能总线; VPB:连接片内外设功能的VLSI外设总线; EMC:外部存储器…...

7-1、2、3 IPFS介绍使用及浏览器交互(react+区块链实战)
7-1、2、3 IPFS介绍使用及浏览器交互(react区块链实战) 7-1 ipfs介绍7-2 IPFS-desktop使用7-3 reactipfs-api浏览器和ipfs交互 7-1 ipfs介绍 IPFS区块链上的文件系统 https://ipfs.io/ 这个网站本身是需要科学上网的 Ipfs是点对点的分布式系统 无限…...

CentOS 7 中出现 cannot open Packages database in /var/lib/rpm 错误
转载自:https://www.jianshu.com/p/423306f43e72 # 进入 rpmdb 所在目录 [roothostbase ~]# cd /var/lib/rpm [roothostbase rpm]# ls Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5 Conflictname __db.002 Dirnames Ins…...

【java深入学习第6章】深入解析Spring事件监听机制
在Spring框架中,事件监听机制是一个强大且灵活的功能,允许我们在应用程序中发布和监听事件。这种机制可以帮助我们实现松耦合的设计,使得不同模块之间的通信更加灵活和可维护。本文将详细介绍Spring的事件监听机制,并通过代码示例…...

Flask与Celery实现Python调度服务
文章目录 Flask与Celery实现Python调度服务一、前言1.组件2.场景说明3.环境 二、安装依赖1.安装Anaconda3.安装redis2.安装依赖包 三、具体实现1.目录结构2.业务流程3.配置文件4.Celery程序5.Flask程序6.测试脚本7.程序启动1)Windows开发调试2)Linux服务…...

Eureka应用场景和优势
Eureka是一款由Netflix开源的服务注册与发现框架,在微服务架构中扮演着至关重要的角色。以下是Eureka的应用场景和优势: Eureka的应用场景 Eureka主要应用于微服务架构中,特别是在大型、复杂的分布式系统中,用于管理和发现服务。…...

prompt第三讲-PromptTemplate
文章目录 前提回顾PromptTemplateprompt 模板定义以f-string渲染格式以mustache渲染格式以jinja2渲染格式直接实例化PromptTemplatePromptTemplate核心变量 prompt value生成invokeformat_prompt(不建议使用)format(不建议使用) batchstreamainvoke PromptTemplate核心方法part…...

卷积神经网络图像识别车辆类型
卷积神经网络图像识别车辆类型 1、图像 自行车: 汽车: 摩托车: 2、数据集目录 3、流程 1、获取数据,把图像转成矩阵,并随机划分训练集、测试集 2、把标签转为数值,将标签向量转换为二值矩阵 3、图像数据归一化,0-1之间的值 4、构造卷积神经网络 5、设置图像输入…...

【接口设计】用 Swagger 实现接口文档
用 Swagger 实现接口文档 1.配置 Swagger1.1 添加 Swagger 依赖1.2 创建 Swagger 配置类 2.编写接口文档 在项目开发中,一般都是由前后端工程师共同定义接口,编写接口文档,之后大家根据这个接口文档进行开发、维护。为了便于编写和维护稳定&a…...

TensorFlow系列:第四讲:MobileNetV2实战
一. 加载数据集 编写工具类,实现数据集的加载 import keras""" 加载数据集工具类 """class DatasetLoader:def __init__(self, path_url, image_size(224, 224), batch_size32, class_modecategorical):self.path_url path_urlself…...

Redis+Caffeine 实现两级缓存实战
RedisCaffeine 实现两级缓存 背景 事情的开始是这样的,前段时间接了个需求,给公司的商城官网提供一个查询预计送达时间的接口。接口很简单,根据请求传的城市仓库发货时间查询快递的预计送达时间。因为商城下单就会调用这个接口ÿ…...