网站怎么做图片动态图片大全wordpress网站很慢

news/2025/9/24 4:32:27/文章来源:
网站怎么做图片动态图片大全,wordpress网站很慢,网站建设费如何核算,工信部网站备案登录作者#xff1a;木木匠 http://my.oschina.net/luozhou/blog/3088908前言我们知道 SpringBoot 给我们带来了一个全新的开发体验#xff0c;我们可以直接把 web 程序达成 jar 包#xff0c;直接启动#xff0c;这就得益于 SpringBoot 内置了容器#xff0c;可以直接启动木木匠 http://my.oschina.net/luozhou/blog/3088908前言我们知道 SpringBoot 给我们带来了一个全新的开发体验我们可以直接把 web 程序达成 jar 包直接启动这就得益于 SpringBoot 内置了容器可以直接启动本文将以 Tomcat 为例来看看 SpringBoot 是如何启动 Tomcat 的同时也将展开学习下 Tomcat 的源码了解 Tomcat 的设计。从 Main 方法说起用过 SpringBoot 的人都知道首先要写一个 main 方法来启动SpringBootApplication public class TomcatdebugApplication {public static void main(String[] args) {SpringApplication.run(TomcatdebugApplication.class, args);}}我们直接点击 run 方法的源码跟踪下来发下最终的 run 方法是调用 ConfigurableApplicationContext 方法源码如下public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch new StopWatch();stopWatch.start();ConfigurableApplicationContext context null;Collectionspringbootexceptionreporter exceptionReporters new ArrayListlt;gt;();//设置系统属性『java.awt.headless』为true则启用headless模式支持configureHeadlessProperty();//通过*SpringFactoriesLoader*检索*META-INF/spring.factories*//找到声明的所有SpringApplicationRunListener的实现类并将其实例化//之后逐个调用其started()方法广播SpringBoot要开始执行了SpringApplicationRunListeners listeners getRunListeners(args);//发布应用开始启动事件listeners.starting();try {//初始化参数ApplicationArguments applicationArguments new DefaultApplicationArguments(args);//创建并配置当前SpringBoot应用将要使用的Environment包括配置要使用的PropertySource以及Profile,//并遍历调用所有的SpringApplicationRunListener的environmentPrepared()方法广播Environment准备完毕。ConfigurableEnvironment environment prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);//打印bannerBanner printedBanner printBanner(environment);//创建应用上下文context createApplicationContext();//通过*SpringFactoriesLoader*检索*META-INF/spring.factories*获取并实例化异常分析器exceptionReporters getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);//为ApplicationContext加载environment之后逐个执行ApplicationContextInitializer的initialize()方法来进一步封装ApplicationContext//并调用所有的SpringApplicationRunListener的contextPrepared()方法【EventPublishingRunListener只提供了一个空的contextPrepared()方法】//之后初始化IoC容器并调用SpringApplicationRunListener的contextLoaded()方法广播ApplicationContext的IoC加载完成//这里就包括通过**EnableAutoConfiguration**导入的各种自动配置类。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);//遍历所有注册的ApplicationRunner和CommandLineRunner并执行其run()方法。//我们可以实现自己的ApplicationRunner或者CommandLineRunner来对SpringBoot的启动过程进行扩展。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;}其实这个方法我们可以简单的总结下步骤为 1. 配置属性 2. 获取监听器发布应用开始启动事件 3. 初始化输入参数 4. 配置环境输出 banner 5. 创建上下文 6. 预处理上下文 7. 刷新上下文 8. 再刷新上下文 9. 发布应用已经启动事件 10. 发布应用启动完成事件其实上面这段代码如果只要分析 tomcat 内容的话只需要关注两个内容即可上下文是如何创建的上下文是如何刷新的分别对应的方法就是 createApplicationContext() 和 refreshContext(context)接下来我们来看看这两个方法做了什么。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);}这里就是根据我们的 webApplicationType 来判断创建哪种类型的 Servlet,代码中分别对应着 Web 类型(SERVLET),响应式 Web 类型REACTIVE),非 Web 类型default),我们建立的是 Web 类型所以肯定实例化 DEFAULT_SERVLET_WEB_CONTEXT_CLASS 指定的类也就是 AnnotationConfigServletWebServerApplicationContext 类我们来用图来说明下这个类的关系通过这个类图我们可以知道这个类继承的是 ServletWebServerApplicationContext,这就是我们真正的主角而这个类最终是继承了 AbstractApplicationContext了解完创建上下文的情况后我们再来看看刷新上下文相关代码如下//类SpringApplication.javaprivate void refreshContext(ConfigurableApplicationContext context) {//直接调用刷新方法refresh(context);if (this.registerShutdownHook) {try {context.registerShutdownHook();}catch (AccessControlException ex) {// Not allowed in some environments.}}} //类SpringApplication.javaprotected void refresh(ApplicationContext applicationContext) {Assert.isInstanceOf(AbstractApplicationContext.class, applicationContext);((AbstractApplicationContext) applicationContext).refresh();}这里还是直接传递调用本类的 refresh(context)方法最后是强转成父类 AbstractApplicationContext 调用其 refresh()方法,该代码如下// 类AbstractApplicationContext public void refresh() throws BeansException, IllegalStateException {synchronized (this.startupShutdownMonitor) {// Prepare this context for refreshing.prepareRefresh();// Tell the subclass to refresh the internal bean factory.ConfigurableListableBeanFactory beanFactory obtainFreshBeanFactory();// Prepare the bean factory for use in this context.prepareBeanFactory(beanFactory);try {// Allows post-processing of the bean factory in context subclasses.postProcessBeanFactory(beanFactory);// Invoke factory processors registered as beans in the context.invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation.registerBeanPostProcessors(beanFactory);// Initialize message source for this context.initMessageSource();// Initialize event multicaster for this context.initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses.这里的意思就是调用各个子类的onRefresh()onRefresh();// Check for listener beans and register them.registerListeners();// Instantiate all remaining (non-lazy-init) singletons.finishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.finishRefresh();}catch (BeansException ex) {if (logger.isWarnEnabled()) {logger.warn(Exception encountered during context initialization - cancelling refresh attempt: ex);}// Destroy already created singletons to avoid dangling resources.destroyBeans();// Reset active flag.cancelRefresh(ex);// Propagate exception to caller.throw ex;}finally {// Reset common introspection caches in Springs core, since we// might not ever need metadata for singleton beans anymore...resetCommonCaches();}}}这里我们看到 onRefresh()方法是调用其子类的实现根据我们上文的分析我们这里的子类是 ServletWebServerApplicationContext。//类ServletWebServerApplicationContext protected void onRefresh() {super.onRefresh();try {createWebServer();}catch (Throwable ex) {throw new ApplicationContextException(Unable to start web server, ex);}}private void createWebServer() {WebServer webServer this.webServer;ServletContext servletContext getServletContext();if (webServer null amp;amp; servletContext null) {ServletWebServerFactory factory getWebServerFactory();this.webServer factory.getWebServer(getSelfInitializer());}else if (servletContext ! null) {try {getSelfInitializer().onStartup(servletContext);}catch (ServletException ex) {throw new ApplicationContextException(Cannot initialize servlet context, ex);}}initPropertySources();}到这里其实庐山真面目已经出来了createWebServer()就是启动 web 服务但是还没有真正启动 Tomcat既然 webServer 是通过 ServletWebServerFactory 来获取的我们就来看看这个工厂的真面目。走进 Tomcat 内部根据上图我们发现工厂类是一个接口各个具体服务的实现是由各个子类来实现的所以我们就去看看 TomcatServletWebServerFactory.getWebServer()的实现。Overridepublic WebServer getWebServer(ServletContextInitializer... initializers) {Tomcat tomcat new Tomcat();File baseDir (this.baseDirectory ! null) ? this.baseDirectory : createTempDir(tomcat);tomcat.setBaseDir(baseDir.getAbsolutePath());Connector connector new Connector(this.protocol);tomcat.getService().addConnector(connector);customizeConnector(connector);tomcat.setConnector(connector);tomcat.getHost().setAutoDeploy(false);configureEngine(tomcat.getEngine());for (Connector additionalConnector : this.additionalTomcatConnectors) {tomcat.getService().addConnector(additionalConnector);}prepareContext(tomcat.getHost(), initializers);return getTomcatWebServer(tomcat);}根据上面的代码我们发现其主要做了两件事情第一件事就是把 Connnctor(我们称之为连接器)对象添加到 Tomcat 中第二件事就是 configureEngine,这连接器我们勉强能理解不理解后面会述说那这个 Engine 是什么呢我们查看 tomcat.getEngine()的源码public Engine getEngine() {Service service getServer().findServices()[0];if (service.getContainer() ! null) {return service.getContainer();}Engine engine new StandardEngine();engine.setName( Tomcat );engine.setDefaultHost(hostname);engine.setRealm(createDefaultRealm());service.setContainer(engine);return engine;}根据上面的源码我们发现原来这个 Engine 是容器我们继续跟踪源码找到 Container 接口上图中我们看到了 4 个子接口分别是 Engine,Host,Context,Wrapper。我们从继承关系上可以知道他们都是容器那么他们到底有啥区别呢我看看他们的注释是怎么说的。/**If used, an Engine is always the top level Container in a Catalina* hierarchy. Therefore, the implementations codesetParent()/code method* should throw codeIllegalArgumentException/code.** author Craig R. McClanahan*/ public interface Engine extends Container {//省略代码 } /*** p* The parent Container attached to a Host is generally an Engine, but may* be some other implementation, or may be omitted if it is not necessary.* /pp* The child containers attached to a Host are generally implementations* of Context (representing an individual servlet context).** author Craig R. McClanahan*/ public interface Host extends Container { //省略代码} /*** /pp* The parent Container attached to a Context is generally a Host, but may* be some other implementation, or may be omitted if it is not necessary.* /pp* The child containers attached to a Context are generally implementations* of Wrapper (representing individual servlet definitions).* /pp** author Craig R. McClanahan*/ public interface Context extends Container, ContextBind {//省略代码 } /**/pp* The parent Container attached to a Wrapper will generally be an* implementation of Context, representing the servlet context (and* therefore the web application) within which this servlet executes.* /pp* Child Containers are not allowed on Wrapper implementations, so the* codeaddChild()/code method should throw an* codeIllegalArgumentException/code.** author Craig R. McClanahan*/ public interface Wrapper extends Container {//省略代码 }上面的注释翻译过来就是Engine 是最高级别的容器其子容器是 Host,Host 的子容器是 Context,Wrapper 是 Context 的子容器所以这 4 个容器的关系就是父子关系也就是 EngineHostContextWrapper。我们再看看 Tomcat 类的源码://部分源码其余部分省略。 public class Tomcat { //设置连接器public void setConnector(Connector connector) {Service service getService();boolean found false;for (Connector serviceConnector : service.findConnectors()) {if (connector serviceConnector) {found true;}}if (!found) {service.addConnector(connector);}}//获取servicepublic Service getService() {return getServer().findServices()[0];}//设置Host容器public void setHost(Host host) {Engine engine getEngine();boolean found false;for (Container engineHost : engine.findChildren()) {if (engineHost host) {found true;}}if (!found) {engine.addChild(host);}}//获取Engine容器public Engine getEngine() {Service service getServer().findServices()[0];if (service.getContainer() ! null) {return service.getContainer();}Engine engine new StandardEngine();engine.setName( Tomcat );engine.setDefaultHost(hostname);engine.setRealm(createDefaultRealm());service.setContainer(engine);return engine;}//获取serverpublic Server getServer() {if (server ! null) {return server;}System.setProperty(catalina.useNaming, false);server new StandardServer();initBaseDir();// Set configuration sourceConfigFileLoader.setSource(new CatalinaBaseConfigurationSource(new File(basedir), null));server.setPort( -1 );Service service new StandardService();service.setName(Tomcat);server.addService(service);return server;}//添加Context容器public Context addContext(Host host, String contextPath, String contextName,String dir) {silence(host, contextName);Context ctx createContext(host, contextPath);ctx.setName(contextName);ctx.setPath(contextPath);ctx.setDocBase(dir);ctx.addLifecycleListener(new FixContextListener());if (host null) {getHost().addChild(ctx);} else {host.addChild(ctx);}//添加Wrapper容器public static Wrapper addServlet(Context ctx,String servletName,Servlet servlet) {// will do class for name and set init paramsWrapper sw new ExistingStandardWrapper(servlet);sw.setName(servletName);ctx.addChild(sw);return sw;}}阅读 Tomcat 的 getServer()我们可以知道Tomcat 的最顶层是 Server,Server 就是 Tomcat 的实例一个 Tomcat 一个 Server;通过 getEngine()我们可以了解到 Server 下面是 Service而且是多个一个 Service 代表我们部署的一个应用而且我们还可以知道Engine 容器一个 service 只有一个根据父子关系我们看 setHost()源码可以知道host 容器有多个同理我们发现 addContext()源码下Context 也是多个addServlet()表明 Wrapper 容器也是多个而且这段代码也暗示了其实 Wrapper 和 Servlet 是一层意思。另外我们根据 setConnector 源码可以知道连接器(Connector)是设置在 service 下的而且是可以设置多个连接器(Connector)。根据上面分析我们可以小结下Tomcat 主要包含了 2 个核心组件连接器(Connector)和容器(Container),用图表示如下一个 Tomcat 是一个 Server,一个 Server 下有多个 service也就是我们部署的多个应用一个应用下有多个连接器(Connector)和一个容器Container,容器下有多个子容器关系用图表示如下Engine 下有多个 Host 子容器Host 下有多个 Context 子容器Context 下有多个 Wrapper 子容器。总结SpringBoot 的启动是通过 new SpringApplication()实例来启动的启动过程主要做如下几件事情 1. 配置属性 2. 获取监听器发布应用开始启动事件 3. 初始化输入参数 4. 配置环境输出 banner 5. 创建上下文 6. 预处理上下文 7. 刷新上下文 8. 再刷新上下文 9. 发布应用已经启动事件 10. 发布应用启动完成事件而启动 Tomcat 就是在第 7 步中“刷新上下文”Tomcat 的启动主要是初始化 2 个核心组件连接器(Connector)和容器Container一个 Tomcat 实例就是一个 Server一个 Server 包含多个 Service也就是多个应用程序每个 Service 包含多个连接器Connetor和一个容器Container),而容器下又有多个子容器按照父子关系分别为Engine,Host,Context,Wrapper其中除了 Engine 外其余的容器都是可以有多个。

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

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

相关文章

paypal网站做外贸经销商自己做网站合适吗

正题 题目大意 nnn个点每个点之间的边权是一个周期。 求从111出发经过mmm条边到nnn的最小权值 解题思路 分成mmm层表示天数&#xff0c;然后连边跑SPFASPFASPFA codecodecode #include<cstdio> #include<queue> #include<cstring> #define N 40100 using …

体育视频网站建设网站更换域名备案

学习 Jedis、RedisTemplate、StringRedisTemplate之间的比较 博客中提到&#xff1a;一. Jedis是Redis官方推荐的面向Java的操作Redis的客户端。 二. RedisTemplate,StringRedisTemplate是SpringDataRedis中对JedisApi的高度封装。SpringDataRedis相对于Jedis来说可以方便地更…

网站的交互怎么做asp网站下用php栏目

上期文章我们分享了如何使用LetNet体系结构来搭建一个图片识别的神经网络: 人工智能Keras的第一个图像分类器(CNN卷积神经网络的图片识别) 本期我们基于VGGNet神经网络来进行图片的识别,且增加图片的识别种类,当然你也可以增加更多的种类,本期代码跟往期代码有很大的相…

ti外包网站建设wordpress 插件 支付

背景 最近在研究tomcat调优的问题&#xff0c;开发人员做过的最多的tomcat调优想必就是线程池调优了&#xff0c;但是tomcat并没有使用jdk自己的线程池实现&#xff0c;而是自定了了线程池&#xff0c;自己实现了ThreadPoolExecutor类位于org.apache.tomcat.util.threads包下 …

做爰全程的网站文安做网站的

使用 Tailwind CSS 完成导航栏效果 本文将向您介绍如何使用 Tailwind CSS 创建一个漂亮的导航栏。通过逐步演示和示例代码&#xff0c;您将学习如何使用 Tailwind CSS 的类来设计和定制导航栏的样式。 准备工作 在开始之前&#xff0c;请确保已经安装了 Tailwind CSS。如果没…

为你的数据选择合适的分布:8个实用的概率分布应用场景和选择指南

拿到数据想建模,但不知道用哪个分布?大部分教科书都在讲一堆你永远用不到的东西。实际工作中,你只需要掌握几个核心分布,然后知道什么时候该用哪个就够了。 这里是我在做分析、实验设计、风险建模时真正会用的8个分…

wordpress网站映射简历电子版模板免费下载

原标题&#xff1a;Linux Kernel 4.4.19 LTS长期支持版发布摘要&#xff1a;近日&#xff0c;内核开发者Greg Kroah-Hartman公布了长期支持的Linux 4.4 Kernel系列第19个维护版本的细节。Linux 4.4是目前最新的LTS内核分支&#xff0c;被Arch Linux, Solus和Ubuntu Linux等众多…

五百亿建站模板重庆建工集团股份有限公司官网

BigDeciaml1. BigDecimal1. BigDecimal 我们知道&#xff0c;关于金钱相关的计算&#xff0c;都用BigDeciaml数据类型, 来表示金额。所有关于金额的项目中不能缺少它的使用。 而我今天说说用这个类型&#xff0c;踩到的坑。 金额比较问题 带精度不适用equals比较。使用compar…

浙江网站建设推广公司哪家好百度服务电话

** Java学习 第三章 数组&#xff08;三&#xff09;排序算法 ** 主要内容&#xff1a;排序算法、排序算法横向比较、Arrays工具类的使用、数组常见异常 1.数组中涉及到的常见算法&#xff1a;排序算法 1.1 排序算法分类&#xff1a;内部排序和外部排序 1.2 十大内部排序算…

专业手机网站建设推荐长春几个火车站啊

科技巨头的AI之战持续上演&#xff0c;而财报季是一窥AI成色的重要窗口。 谷歌和微软这对在多个领域均正面对决的科技巨头&#xff0c;又在同一日发布了财报&#xff0c;而这次相比上季度&#xff0c;战局似乎迎来了反转。 上季度&#xff0c;谷歌不仅成功抵御了Bing联手ChatG…

龙岩做网站开发价格京津冀协同发展意义

mvn archetype:create -DgroupIdcom.mycompany.app -DartifactIdmyWeb -DarchetypeArtifactIdmaven-archetype-webapp 转载于:https://www.cnblogs.com/alaricblog/p/3278239.html

网站特效 站长做属于公司的网站有什么好处

计算机网络21-40 以下是本文参考的资料 欢迎大家查收原版 本版本仅作个人笔记使用21、HTTPS是如何保证数据传输的安全&#xff0c;整体的流程是什么&#xff1f;&#xff08;SSL是怎么工作保证安全&#xff09;对称加密非对称加密消息认证码 (MAC)数字证书 22、如何保证公钥不被…

网站的关键词可以取消吗济南百度提升优化

作为一个芯片公司打杂人口&#xff0c;往往需要一个皮实耐打上天入地的编辑器… 一、先附上github路径&#xff0c;方便取走 git clone gitgithub.com:qqqw4549/vim_config_c_verilog.git 二、效果展示 支持ctrl]函数/模块跳转&#xff0c;支持cscope字串全局代码搜索 依赖&am…

天津百度爱采购重庆整站优化的电话销售

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到教程。 Web服务器收到一个http请求&#xff0c;会针对每个请求创建一个HttpServletRequest和HttpServletResponse对象&#xff0c; 从客户端取…

如何宣传商务网站网站怎样优化seo

目录 流程控制之条件判断 2.1.if语句语法 2.1.1单分支结构 2.1.2双分支结构 2.1.3多分支结构 2.2.案例 例一: 例2: 例3: 例4: 例5: 例6: 例7: 例8: 例9: 2.3.case多条件判断 2.3.1.格式 2.3.2.执行过程 例10: 流程控制之条件判断 2.1.if语句语法 2.1.1单分…

佛山市手机网站建设企业企业大黄页

/Bin存放系统命令 /etc存放系统命令及配置文件的数据库 /lib存放C语言的库函数、数据库 /mnt存放可拆装的软件 /Tmp存放临时文件 /user存放用户目录 转载于:https://www.cnblogs.com/Ewin/archive/2008/12/22/1360111.html

怎么查找网站是谁做的建站开发软件

每个开发都会涉及到一个工作&#xff0c;就是网站开发。开发过程势必会涉及到需要对网站加速的部分&#xff0c;很多开发同学对此都很是头疼。 想让网站跑起来飞快&#xff0c;必须用上个网站加速神器&#xff0c;很多人都会推荐CDN。CDN的原理就是把网站文件提前搬到全国各地…

网站建设维护课件ppt销售渠道策略

使用PostMan可以方便快速的进行跨域测试。 只需要在请求头中手动添加一个Origin的标头&#xff0c;声明需要跨域跨到的域&#xff08;IP&#xff1a;端口&#xff09;就行&#xff0c;其余参数PostMan会自动生成。添加此标头后&#xff0c;请求会被做为一条跨域的请求来进行处…

资中移动网站建设wordpress move导入数据

个人主页&#xff1a;insist--个人主页​​​​​​ 本文专栏&#xff1a;网络基础——带你走进网络世界 本专栏会持续更新网络基础知识&#xff0c;希望大家多多支持&#xff0c;让我们一起探索这个神奇而广阔的网络世界。 目录 一、网络设备的概述 二、常见的网络设备 1、…

中国建设银行网站对公业务大连市建设学校网站

华为PPPOE配置实验 网络拓扑图拓扑说明电信ISP设备配置用户拨号路由器配置查看是否拨上号是否看不懂&#xff1f; 看不懂就对了&#xff0c;只是记录一下命令。至于所有原理&#xff0c;等想写了再写 网络拓扑图 拓扑说明 用户路由器用于模拟家用拨号路由器&#xff0c;该设备…