spring mvc源码学习笔记之六
- pom.xml 内容如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.qsm</groupId><artifactId>learn</artifactId><version>1.0.0</version></parent><groupId>com.qs.demo</groupId><artifactId>demo-077</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.3.28</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version><scope>provided</scope></dependency></dependencies></project>
- com.qs.demo.MyWebApplicationInitializer 内容如下
package com.qs.demo;import com.qs.demo.root.AppConfig;
import com.qs.demo.sub.DispatcherConfig;import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;/*** @author qs* @date 2024/09/24*/
public class MyWebApplicationInitializer implements WebApplicationInitializer {// 这个例子来自于 WebApplicationInitializer 的文档@Overridepublic void onStartup(ServletContext container) {// Create the 'root' Spring application contextAnnotationConfigWebApplicationContext rootContext =new AnnotationConfigWebApplicationContext();rootContext.register(AppConfig.class);// Manage the lifecycle of the root application contextcontainer.addListener(new ContextLoaderListener(rootContext));// Create the dispatcher servlet's Spring application contextAnnotationConfigWebApplicationContext dispatcherContext =new AnnotationConfigWebApplicationContext();dispatcherContext.register(DispatcherConfig.class);// Register and map the dispatcher servletServletRegistration.Dynamic dispatcher =container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));dispatcher.setLoadOnStartup(1);// 一个 DispatcherServlet 包圆了所有的请求// 可以搞多个 DispatcherServlet 分别处理不同的请求dispatcher.addMapping("/");}
}
- com.qs.demo.root.AppConfig 内容如下
package com.qs.demo.root;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;/*** @author qs* @date 2024/09/24*/
@Configuration
@ComponentScan("com.qs.demo.root")
public class AppConfig {}
- com.qs.demo.root.AppleService 内容如下
package com.qs.demo.root;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;import java.util.UUID;/*** @author qs* @date 2024/09/24*/
@Service
public class AppleService implements ApplicationContextAware {private ApplicationContext applicationContext;public String a() {System.out.println(applicationContext);return UUID.randomUUID().toString();}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {this.applicationContext = applicationContext;}
}
- com.qs.demo.sub.DispatcherConfig 内容如下
package com.qs.demo.sub;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;/*** @author qs* @date 2024/09/24*/
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = "com.qs.demo.sub")
public class DispatcherConfig {}
- com.qs.demo.sub.BananaService 内容如下
package com.qs.demo.sub;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;import java.util.UUID;/*** @author qs* @date 2024/09/24*/
@Service
public class BananaService implements ApplicationContextAware {public String a() {return UUID.randomUUID().toString();}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {System.out.println(applicationContext);}
}
- com.qs.demo.sub.Demo01Controller 内容如下
package com.qs.demo.sub;import com.qs.demo.root.AppleService;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import javax.annotation.Resource;/*** @author qs* @date 2024/09/24*/
@RestController
public class Demo01Controller {@Resource private AppleService appleService;@Resource private BananaService bananaService;@GetMapping("/01")public String a() {return "01";}@GetMapping("/02")public String b() {return appleService.a();}@GetMapping("/03")public String c() {return bananaService.a();}
}
以上就是全部代码
写这个例子主要是为了介绍 WebApplicationInitializer 这个接口。简单点儿讲就是这个接口等价于 web.xml 这个配置文件。
写了这个接口就不用写 web.xml 配置文件了。
下面重点看下这个接口的 javadoc
/**
* <p>
* 下面这段话的关键点:
* 1、适用于 servlet 3.0+ 环境
* 2、该接口可以看做是传统的 web.xml 的替代品
* </p>
*
* Interface to be implemented in Servlet 3.0+ environments in order to configure the
* {@link ServletContext} programmatically -- as opposed to (or possibly in conjunction
* with) the traditional {@code web.xml}-based approach.
*
* <p>
* 下面这段话的意思:
* 1、该接口的实现会自动被 SpringServletContainerInitializer 检测到
* 2、而 SpringServletContainerInitializer 又会被 servlet 3.0 容器自动带起来
* </p>
*
* <p>Implementations of this SPI will be detected automatically by {@link
* SpringServletContainerInitializer}, which itself is bootstrapped automatically
* by any Servlet 3.0 container. See {@linkplain SpringServletContainerInitializer its
* Javadoc} for details on this bootstrapping mechanism.
*
* <p>注意下面这个例子。看本接口是怎样替换 web.xml 配置的</p>
*
* <h2>Example</h2>
* <h3>The traditional, XML-based approach</h3>
* Most Spring users building a web application will need to register Spring's {@code
* DispatcherServlet}. For reference, in WEB-INF/web.xml, this would typically be done as
* follows:
* <pre class="code">
* {@code
* <servlet>
* <servlet-name>dispatcher</servlet-name>
* <servlet-class>
* org.springframework.web.servlet.DispatcherServlet
* </servlet-class>
* <init-param>
* <param-name>contextConfigLocation</param-name>
* <param-value>/WEB-INF/spring/dispatcher-config.xml</param-value>
* </init-param>
* <load-on-startup>1</load-on-startup>
* </servlet>
*
* <servlet-mapping>
* <servlet-name>dispatcher</servlet-name>
* <url-pattern>/</url-pattern>
* </servlet-mapping>}</pre>
*
* <h3>The code-based approach with {@code WebApplicationInitializer}</h3>
* Here is the equivalent {@code DispatcherServlet} registration logic,
* {@code WebApplicationInitializer}-style:
* <pre class="code">
* public class MyWebAppInitializer implements WebApplicationInitializer {
*
* @Override
* public void onStartup(ServletContext container) {
* XmlWebApplicationContext appContext = new XmlWebApplicationContext();
* appContext.setConfigLocation("/WEB-INF/spring/dispatcher-config.xml");
*
* ServletRegistration.Dynamic dispatcher =
* container.addServlet("dispatcher", new DispatcherServlet(appContext));
* dispatcher.setLoadOnStartup(1);
* dispatcher.addMapping("/");
* }
*
* }</pre>
*
* <p>
* 上面的例子是实现 WebApplicationInitializer 接口。
* 也可以继承 AbstractDispatcherServletInitializer 类。
* </p>
*
* As an alternative to the above, you can also extend from {@link
* org.springframework.web.servlet.support.AbstractDispatcherServletInitializer}.
*
* As you can see, thanks to Servlet 3.0's new {@link ServletContext#addServlet} method
* we're actually registering an <em>instance</em> of the {@code DispatcherServlet}, and
* this means that the {@code DispatcherServlet} can now be treated like any other object
* -- receiving constructor injection of its application context in this case.
*
* <p>This style is both simpler and more concise. There is no concern for dealing with
* init-params, etc, just normal JavaBean-style properties and constructor arguments. You
* are free to create and work with your Spring application contexts as necessary before
* injecting them into the {@code DispatcherServlet}.
*
* <p>Most major Spring Web components have been updated to support this style of
* registration. You'll find that {@code DispatcherServlet}, {@code FrameworkServlet},
* {@code ContextLoaderListener} and {@code DelegatingFilterProxy} all now support
* constructor arguments. Even if a component (e.g. non-Spring, other third party) has not
* been specifically updated for use within {@code WebApplicationInitializers}, they still
* may be used in any case. The Servlet 3.0 {@code ServletContext} API allows for setting
* init-params, context-params, etc programmatically.
*
* <p>
* 在上面的例子中,web.xml 被替换了,但是 dispatcher-config.xml 依然存在。
* 下面的例子就彻底摆脱 xml 配置了。
* </p>
*
* <h2>A 100% code-based approach to configuration</h2>
* In the example above, {@code WEB-INF/web.xml} was successfully replaced with code in
* the form of a {@code WebApplicationInitializer}, but the actual
* {@code dispatcher-config.xml} Spring configuration remained XML-based.
* {@code WebApplicationInitializer} is a perfect fit for use with Spring's code-based
* {@code @Configuration} classes. See @{@link
* org.springframework.context.annotation.Configuration Configuration} Javadoc for
* complete details, but the following example demonstrates refactoring to use Spring's
* {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
* AnnotationConfigWebApplicationContext} in lieu of {@code XmlWebApplicationContext}, and
* user-defined {@code @Configuration} classes {@code AppConfig} and
* {@code DispatcherConfig} instead of Spring XML files. This example also goes a bit
* beyond those above to demonstrate typical configuration of the 'root' application
* context and registration of the {@code ContextLoaderListener}:
* <pre class="code">
* public class MyWebAppInitializer implements WebApplicationInitializer {
*
* @Override
* public void onStartup(ServletContext container) {
* // Create the 'root' Spring application context
* AnnotationConfigWebApplicationContext rootContext =
* new AnnotationConfigWebApplicationContext();
* rootContext.register(AppConfig.class);
*
* // Manage the lifecycle of the root application context
* container.addListener(new ContextLoaderListener(rootContext));
*
* // Create the dispatcher servlet's Spring application context
* AnnotationConfigWebApplicationContext dispatcherContext =
* new AnnotationConfigWebApplicationContext();
* dispatcherContext.register(DispatcherConfig.class);
*
* // Register and map the dispatcher servlet
* ServletRegistration.Dynamic dispatcher =
* container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));
* dispatcher.setLoadOnStartup(1);
* dispatcher.addMapping("/");
* }
*
* }</pre>
*
* As an alternative to the above, you can also extend from {@link
* org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer}.
*
* Remember that {@code WebApplicationInitializer} implementations are <em>detected
* automatically</em> -- so you are free to package them within your application as you
* see fit.
*
* <p>
* 多个 WebApplicationInitializer 之间可以指定顺序。但是这种一般不常用。一个 WebApplicationInitializer 就够了。
* </p>
*
* <h2>Ordering {@code WebApplicationInitializer} execution</h2>
* {@code WebApplicationInitializer} implementations may optionally be annotated at the
* class level with Spring's @{@link org.springframework.core.annotation.Order Order}
* annotation or may implement Spring's {@link org.springframework.core.Ordered Ordered}
* interface. If so, the initializers will be ordered prior to invocation. This provides
* a mechanism for users to ensure the order in which servlet container initialization
* occurs. Use of this feature is expected to be rare, as typical applications will likely
* centralize all container initialization within a single {@code WebApplicationInitializer}.
*
* <h2>Caveats</h2>
*
* <p>
* 注意 web.xml 和 WebApplicationInitializer 不是相互排斥的。
* 二者可以同时存在。
* </p>
*
* <h3>web.xml versioning</h3>
* <p>{@code WEB-INF/web.xml} and {@code WebApplicationInitializer} use are not mutually
* exclusive; for example, web.xml can register one servlet, and a {@code
* WebApplicationInitializer} can register another. An initializer can even
* <em>modify</em> registrations performed in {@code web.xml} through methods such as
* {@link ServletContext#getServletRegistration(String)}. <strong>However, if
* {@code WEB-INF/web.xml} is present in the application, its {@code version} attribute
* must be set to "3.0" or greater, otherwise {@code ServletContainerInitializer}
* bootstrapping will be ignored by the servlet container.</strong>
*
* <h3>Mapping to '/' under Tomcat</h3>
* <p>Apache Tomcat maps its internal {@code DefaultServlet} to "/", and on Tomcat versions
* <= 7.0.14, this servlet mapping <em>cannot be overridden programmatically</em>.
* 7.0.15 fixes this issue. Overriding the "/" servlet mapping has also been tested
* successfully under GlassFish 3.1.<p>
*
* @author Chris Beams
* @since 3.1
* @see SpringServletContainerInitializer
* @see org.springframework.web.context.AbstractContextLoaderInitializer
* @see org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
* @see org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer
*/
多说一嘴,这个例子中用到了 DispatcherServlet 的有参构造(DispatcherServlet只有2个构造方法,一个无参一个有参,无参构造在其他文章中介绍了)。
这里就顺便详细看下这个有参构造的 javadoc
/*** 使用给定的 web 应用上下文来创建一个 DispatcherServlet。* 无参的构造是在 DispatcherServlet 内部自己创建维护 web 应用上下文。* 这个有参的构造是用外部传过来的 web 应用上下文。* 这个构造方法主要是用在 servlet 3.0+ 的环境中。* 用了这个构造方法以后,setContextClass setContextConfigLocation setContextAttribute setNamespace 这4个方法就无效了。* 对应的 contextClass contextConfigLocation contextAttribute namespace 等四个 servlet init-param 也无效了。* 传进来的 web 应用上下文可能已经 refresh() 了,也可能没有 refresh()。* 建议是不要 refresh()。* 如果不刷新的话,将会发生这些事情:* 1、如果传进来的web应用上下文还没有设置父应用上下文,则将 root web 应用上下文设置为它的父应用上下文。* 2、如果传进来的web应用上下文还没有设置id,将会给它设置一个id。* 3、将ServletContext和ServletConfig存到web应用上下文中。* 4、postProcessWebApplicationContext 方法会被调用。* 5、ApplicationContextInitializer 会被调用。可以用这个东西对web应用上下文进行自定义配置,其他文章也有提过。* 6、如果传进来的web应用上下文实现了ConfigurableApplicationContext的话,refresh()方法将会被调用。* 如果传进来的web应用上下文已经 refresh() 过了,上面提到的几点都不会发生。* * 另外,这个有参构造怎么用,可以参考 WebApplicationInitializer 接口。这不就跟本文写的代码对应上了么。** Create a new {@code DispatcherServlet} with the given web application context. This* constructor is useful in Servlet 3.0+ environments where instance-based registration* of servlets is possible through the {@link ServletContext#addServlet} API.* <p>Using this constructor indicates that the following properties / init-params* will be ignored:* <ul>* <li>{@link #setContextClass(Class)} / 'contextClass'</li>* <li>{@link #setContextConfigLocation(String)} / 'contextConfigLocation'</li>* <li>{@link #setContextAttribute(String)} / 'contextAttribute'</li>* <li>{@link #setNamespace(String)} / 'namespace'</li>* </ul>* <p>The given web application context may or may not yet be {@linkplain* ConfigurableApplicationContext#refresh() refreshed}. If it has <strong>not</strong>* already been refreshed (the recommended approach), then the following will occur:* <ul>* <li>If the given context does not already have a {@linkplain* ConfigurableApplicationContext#setParent parent}, the root application context* will be set as the parent.</li>* <li>If the given context has not already been assigned an {@linkplain* ConfigurableApplicationContext#setId id}, one will be assigned to it</li>* <li>{@code ServletContext} and {@code ServletConfig} objects will be delegated to* the application context</li>* <li>{@link #postProcessWebApplicationContext} will be called</li>* <li>Any {@code ApplicationContextInitializer}s specified through the* "contextInitializerClasses" init-param or through the {@link* #setContextInitializers} property will be applied.</li>* <li>{@link ConfigurableApplicationContext#refresh refresh()} will be called if the* context implements {@link ConfigurableApplicationContext}</li>* </ul>* If the context has already been refreshed, none of the above will occur, under the* assumption that the user has performed these actions (or not) per their specific* needs.* <p>See {@link org.springframework.web.WebApplicationInitializer} for usage examples.* @param webApplicationContext the context to use* @see #initWebApplicationContext* @see #configureAndRefreshWebApplicationContext* @see org.springframework.web.WebApplicationInitializer*/
public DispatcherServlet(WebApplicationContext webApplicationContext) {super(webApplicationContext);setDispatchOptionsRequest(true);
}
相关文章:
spring mvc源码学习笔记之六
pom.xml 内容如下 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/P…...
深入理解 PyTorch 的 Dataset 和 DataLoader:构建高效数据管道
文章目录 简介PyTorch 的 DatasetDataset 的基本概念自定义 Dataset实现 __init__ 方法示例:从 CSV 文件加载数据 实现 __len__ 方法实现 __getitem__ 方法另一种示例:直接传递列表训练集和验证集的定义 1. 单个 Dataset 类 数据分割2. 分别定义两个 Da…...
VSCode设置ctrl或alt+mouse(left)跳转
总结: (1)VSCode初次远程连接服务器时,需要在服务器上下载 python 拓展,然后选择对应的环境 (2)VSCode设置ctrl或altmouse(left)跳转到定义...
在Ubuntu 18.04.6 LTS安装OpenFace流程
一、修改配置:将gcc8,g8作为默认选项 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 sudo update-alternatives --config gcc 选择版本,再查看gcc --version sudo update-alternatives --install /usr/bin/g g /usr/bin/g-…...
微服务拆分的艺术:构建高效、灵活的系统架构
目录 一、微服务拆分的重要性 二、微服务拆分的策略 1. 按照业务领域拆分 2. 按照团队结构拆分 3. 按照业务边界拆分 4. 按照数据和数据库拆分 5. 按照用户界面或外部接口拆分 6. 按照功能模块或领域驱动设计拆分 7. 按照性能和可伸缩性需求拆分 三、微服务拆分的实践…...
PHP框架+gatewayworker实现在线1对1聊天--发送消息(6)
文章目录 发送消息原理说明发送功能实现html部分javascript代码PHP代码 发送消息原理说明 接下来我们发送聊天的文本信息。点击发送按钮的时候,会自动将文本框里的内容发送出去。过程是我们将信息发送到服务器,服务器再转发给对方。文本框的id为msgcont…...
java项目之读书笔记共享平台(源码+文档)
风定落花生,歌声逐流水,大家好我是风歌,混迹在java圈的辛苦码农。今天要和大家聊的是一款基于springboot的闲一品交易平台。项目源码以及部署相关请联系风歌,文末附上联系信息 。 项目简介: 读书笔记共享平台的主要使…...
RabbitMq的Java项目实践
在现代软件开发中,消息队列(Message Queue,简称MQ)作为一种重要的组件,承担着上下游消息传递和通信的重任。RabbitMQ作为一款流行的开源消息队列中间件,凭借其高可用性、可扩展性和易用性等特点,…...
气膜球幕:引领元宇宙时代的科技与艺术光影盛宴—轻空间
在科技与艺术交织的时代,未来的观影体验将不再受限于传统屏幕的束缚。随着气膜球幕的崭新亮相,突破性的光影效果和沉浸式体验让我们走进了一个全新的视听世界。这不仅仅是一个简单的球形影院,它是连接现实与虚拟、科技与艺术、光与影的桥梁&a…...
行为模式2.命令模式------灯的开关
行为型模式 模板方法模式(Template Method Pattern)命令模式(Command Pattern)迭代器模式(Iterator Pattern)观察者模式(Observer Pattern)中介者模式(Mediator Pattern…...
Linux环境下静态库和动态库的实现
Linux 环境下静态库和动态库的实现 在软件开发中,库是非常重要的组成部分。它们包含了一组可复用的函数和代码片段,用于提高开发效率和代码质量。在Linux系统中,库分为静态库和动态库两种。本文将介绍它们的实现方式,结合C语言代…...
如何很快将文件转换成另外一种编码格式?编码?按指定编码格式编译?如何检测文件编码格式?Java .class文件编码和JVM运行期内存编码?
如何很快将文件转换成另外一种编码格式? 利用VS Code右下角的"选择编码"功能,选择"通过编码保存"可以很方便将文件转换成另外一种编码格式。尤其,在测试w/ BOM或w/o BOM, 或者ANSI编码和UTF编码转换,特别方便。VS文件另…...
Tortoisegit 安装之后没有Add、ignore解决
在本地的仓库文件夹中点击右键,找到Settings, 从General 找到Contex Menu,我的系统是Win11,所以用Win11 Contex Menu 将所需要的操作打勾即可。...
线性代数考研笔记
行列式 背景 分子行列式:求哪个未知数,就把b1,b2放在对应的位置 分母行列式:系数对应写即可 全排列与逆序数 1 3 2:逆序数为1 奇排列 1 2 3:逆序数为0 偶排列 将 1 3 2 只需将3 2交换1次就可以还原原…...
C语言带参数的宏定义的相关知识汇总(最常用的形式、带标记分隔符##的形式...)
阅读大型C工程代码时,绕不开带参数的宏定义的阅读,所以有必要强化一下这一块的知识。 01-带参数的宏定义最常用的形式 # define S(a,b) a*b ... ... ... area S(3,2);则在编译预处理时area S(3,2);被展开为: area 3 * 2;02-带标记分隔符…...
cpp编译链接等
一、编译预处理 C程序编译的过程:预处理 -> 编译(优化、汇编)-> 链接 预处理指令主要有以下三种: 包含头文件:#include 宏定义:#define(定义宏)、#undef(删除宏…...
openbmc sdk09.03 适配(一)
1.说明 本节是根据最新的sdk09.03适配ast2600平台。 sdk下载路径为: https://github.com/AspeedTech-BMC/openbmc可参阅文档: https://blog.csdn.net/wit_yuan/article/details/144613247nfs挂载方法: # mount -o nolock -t nfs serverip:/xx...
JavaScript HTML DOM 实例
JavaScript HTML DOM 实例 JavaScript 的 HTML DOM(文档对象模型)允许您通过脚本来控制 HTML 页面。DOM 是 HTML 文档的编程接口,它将 Web 页面与编程语言连接起来,使得开发者可以改变页面中的内容、结构和样式。在这篇文章中,我们将通过一系列实例来探讨如何使用 JavaSc…...
【Vue】:解决动态更新 <video> 标签 src 属性后视频未刷新的问题
问题描述 在 Vue.js 项目,当尝试动态更新 <video> 标签的 <source> 元素 src 属性来切换视频时,遇到了一个问题:即使 src 属性已更改,浏览器仍显示旧视频。具体表现为用户选择新视频后,视频区域继续显示之…...
C语言| 二维数字的定义
【二维数组】 二维数组的本质就是一维数组,表现形式上是二维的。 定义一般形式为 类型说明符 数组名[常量表达式][常量表达式]; 举例 int a[2][3]; 定义了一个2行3列的二维数组a,共有6个元素。 元素名字依次是:a[0][0],a[0][1],a[0][…...
全国青少年信息学奥林匹克竞赛(信奥赛)备考实战之循环结构(for循环语句)—(十)(求解数学中特殊的数)
实战训练1—完全数 问题描述: 数学上的“完全数”是指真因子(除了自身以外的约数)之和等于它本身的自然数。例如,6的因子是1,2,3,而1236,所以6是完全数。如果一个正整数小于它的所有真因数之和࿰…...
【大模型】ChatGPT 数据分析与处理使用详解
目录 一、前言 二、AI 大模型数据分析介绍 2.1 什么是AI数据分析 2.2 AI数据分析与传统数据分析对比 2.2.1 差异分析 2.2.2 优劣势对比 2.3 AI大模型工具数据分析应用场景 三、AI大模型工具数据分析操作实践 3.1 ChatGPT 常用数据分析技巧操作演示 3.1.1 快速生成数据…...
[gcc]常见编译开关
GCC 提供了许多编译开关(编译选项),这些开关可以用于控制编译过程的各种方面,如优化级别、调试信息、警告和错误处理等。 以下是一些常见的 GCC 编译开关: -o:指定输出文件名。例如,gcc -o myp…...
iOS实现在collectionView顶部插入数据效果
有时候,我们会遇到这种需求,就是下拉刷新的时候,在 collectionView顶部插入数据,这个时候,需要我们注意 主要有两点 1 关闭隐式动画 由于我们使用insert在collectionView顶部插入数据是有从头部插入的隐式动画的&#…...
GPIO、RCC库函数
void GPIO_DeInit(GPIO_TypeDef* GPIOx); void GPIO_AFIODeInit(void); void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); //输出 读 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx,…...
PostgreSQL学习笔记(一):PostgreSQL介绍和安装
目录 概念 PostgreSQL简介 PostgreSQL的关键特性 1. 标准兼容性 2. 扩展性 3. 数据完整性和可靠性 4. 丰富的数据类型 5. 查询能力 6. 事务和并发控制 7. 扩展和插件 8. 跨平台和多语言支持 9. 高可用性和扩展性 常用场景 安装 Linux apt安装 下载安装包安装 客…...
从摩托罗拉手机打印短信的简单方法
昨天我试图从摩托罗拉智能手机上打印短信,但当我通过USB将手机连接到电脑时,我在电脑上找不到它们。由于我的手机内存已达到限制,并且我想保留短信的纸质版本,您能帮我将短信从摩托罗拉手机导出到计算机吗? 如您所知&…...
矩阵运算提速——玩转opencv::Mat
介绍:用Eigen或opencv::Mat进行矩阵的运算,比用cpp的vector或vector进行矩阵运算要快吗? 使用 Eigen 或 OpenCV 的 cv::Mat 进行矩阵运算通常比使用 std::vector<int> 或 std::vector<double> 更快。这主要有以下几个原因: 优化的底层实现…...
vue请求后端需要哪些问题
在使用 Vue 前端框架请求后端服务时,需要考虑和解决的问题有很多。以下是一个详细的讲解: 1. **API 设计与文档** - **明确 API 端点**:了解后端提供的 API 端点(URL),包括资源的路径和操作方法(…...
QML Image详解
1. 概述 Image 是 QML 中用于显示图片的基本组件。它允许开发者加载和显示各种格式的图像文件(如 PNG, JPEG, GIF 等),并提供了多种配置选项来控制图片的显示方式和行为。Image 元素支持各种图像处理功能,比如缩放、裁剪、模糊等…...
Chapter4.1 Coding an LLM architecture
文章目录 4 Implementing a GPT model from Scratch To Generate Text4.1 Coding an LLM architecture 4 Implementing a GPT model from Scratch To Generate Text 本章节包含 编写一个类似于GPT的大型语言模型(LLM),这个模型可以被训练来生…...
Linux 端口知识全解析
Linux 端口知识全解析 在 Linux 系统的网络世界里,端口如同一个个小小的“窗口”,数据的进出都依赖它们有条不紊地运作。理解 Linux 端口知识,无论是对于系统管理员排查网络故障,还是开发者进行网络编程,都至关重要。…...
《Armv8-A virtualization》学习笔记
1.MAIR 的全称是 Memory Attribute Indirection Register。它是ARM架构中的一种寄存器,用于定义内存的属性,并提供一种间接访问内存属性的机制。MAIR寄存器包含多个字段,这些字段指示不同类型内存的属性,例如是否可以缓存、是否为…...
23. 【.NET 8 实战--孢子记账--从单体到微服务】--记账模块--预算
在每个月发工资后很多人会对未来一个月的花销进行大致的计划,这个行为叫做预算。那么在这篇文章中我们将一起开发预算服务。 一、需求 预算需求就是简单的增删改查,虽然比较简单,但是也有几点需要注意。 编号需求说明1新增预算1. 针对每种…...
DOS攻击的原理和实现 (网络安全)hping3和Slowloris的运用
DoS攻击的原理和实现 DoS攻击(Denial of Service Attack,拒绝服务攻击)是指通过恶意手段使目标服务器、服务或网络资源无法正常提供服务,从而影响正常用户的访问。DoS攻击通常通过消耗目标系统的资源(如带宽、内存、处…...
十三、Vue 过渡和动画
文章目录 一、Vue过渡和动画概述1. 过渡的基本原理2. 动画的基本原理二、使用 CSS 过渡1. 单元素过渡2. 过渡模式in - out 模式out - in 模式三、使用 CSS 动画1. 单元素动画2. 动画结合过渡四、JavaScript 钩子函数实现过渡和动画1. 基本概念2. 示例五、列表过渡1. 基本原理2.…...
Dubbo 关键知识点解析:负载均衡、容错、代理及相关框架对比
1.Dubbo 负载均衡策略? Dubbo 是一个分布式服务框架,它提供了多种负载均衡策略来分发服务调用。在 Dubbo 中,负载均衡的实现是基于客户端的,即由服务消费者(Consumer)端决定如何选择服务提供者(…...
仿生的群体智能算法总结之三(十种)
群体智能算法是一类通过模拟自然界中的群体行为来解决复杂优化问题的方法。以下是30种常见的群体智能算法,本文汇总第21-30种。接上文 : 编号 算法名称(英文) 算法名称(中文) 年份 作者 1 Ant Colony Optimization (ACO) 蚁群优化算法 1991 Marco Dorigo 2 Particle Swar…...
《量子比特大阅兵:不同类型量子比特在人工智能领域的优劣势剖析》
在科技的前沿,量子比特与人工智能的融合正开启一扇全新的大门。不同类型的量子比特,如超导、离子阱、光量子等,在与人工智能结合时展现出独特的优势与劣势。 超导量子比特 超导量子比特是目前应用较为广泛且研究相对成熟的量子比特类型。它…...
el-input输入框需要支持多输入,最后传输给后台的字段值以逗号分割
需求:一个输入框字段需要支持多次输入,最后传输给后台的字段值以逗号分割 解决方案:结合了el-tag组件的动态编辑标签 那块的代码 //子组件 <template><div class"input-multiple-box" idinputMultipleBox><div>…...
机器人领域的一些仿真器
模拟工具和环境对于开发、测试和验证可变形物体操作策略至关重要。这些工具提供了一个受控的虚拟环境,用于评估各种算法和模型的性能,并生成用于训练和测试数据驱动模型的合成数据。 Bullet Physics Library 用于可变形物体模拟的一个流行的物理引擎是 B…...
前端-动画库Lottie 3分钟学会使用
目录 1. Lottie地址 2. 使用html实操 3. 也可以选择其他的语言 1. Lottie地址 LottieFiles: Download Free lightweight animations for website & apps.Effortlessly bring the smallest, free, ready-to-use motion graphics for the web, app, social, and designs.…...
腾讯云智能结构化 OCR:驱动多行业数字化转型的核心引擎
在当今数字化时代的汹涌浪潮中,数据已跃升为企业发展的关键要素,其高效、精准的处理成为企业在激烈市场竞争中脱颖而出的核心竞争力。腾讯云智能结构化 OCR 技术凭借其前沿的科技架构与卓越的功能特性,宛如一颗璀璨的明星,在交通、…...
【开源免费】基于SpringBoot+Vue.JS精品在线试题库系统(JAVA毕业设计)
本文项目编号 T 115 ,文末自助获取源码 \color{red}{T115,文末自助获取源码} T115,文末自助获取源码 目录 一、系统介绍二、数据库设计三、配套教程3.1 启动教程3.2 讲解视频3.3 二次开发教程 四、功能截图五、文案资料5.1 选题背景5.2 国内…...
c# CodeFirst生成表字段加注释
前置:ORM框架工具使用的FreeSql 背景:开发环境中运行接口,所有的表字段以及备注会自动加上,但是在测试环境时运行就只生成了表,没有把每个字段的注释加上 问题检查: FreeSql CodeFirst 支持将 c# 代码内的注…...
MySQL8.0复制原理和部署配置步骤
1. mysql 主从复制原理 在从库上执行change master to;会将主库的信息保存到从库中的master.info文件中在从库执行start slave;开启io_thread, sql_thread线程;io_thread工作;io_thread通过master.info文件中主库的连接信息去连接主库;连接成…...
Unity热更新文件修改后缀并拷贝到指定路径的工具类
最近在学习Hybrid热更新。每次编译完,需要修改后缀名和拷贝到特定路径覆盖旧文件,就叫AI写了个工具类。现在记录一下,毕竟ai写完还需要修改。 代码如下,放到Assets/Editor/路径下即可。 可根据需求自行改变路径和文件名。 using…...
前端vue+el-input实现输入框中文字高亮标红效果(学习自掘金博主文章)
学习自掘金文章https://juejin.cn/post/7295169886177918985 该博主的代码基于原生textarea控件和js实现,基于该博主的代码和思路,在vue下实现了相应功能 思路 生成html字符串来实现文字高亮标红效果,但是input输入控件不能渲染html字符串…...
SAP系统中的标准价、移动平均价是什么?有何区别?物料分类账的优点
文章目录 前言一、SAP系统中的价格控制二、移动平均价、标准价是什么?三、S价(标准价)的优势四、S价(标准价)的劣势五、V价(移动平均价)的优势六、V价(移动平均价)的劣势…...
通往O1开源之路
“Scaling of Search and Learning: A Roadmap to Reproduce o1 from Reinforcement Learning Perspective”由复旦大学和上海人工智能实验室的研究者撰写。该论文从强化学习视角出发,深入分析了实现类似OpenAI o1模型性能的路线图,聚焦于策略初始化、奖…...