当前位置: 首页 > news >正文

网站建设 考核指标soe搜索优化

网站建设 考核指标,soe搜索优化,鞋子软文推广300字,wordpress插件如何破解58、嵌入式Servlet容器切换web服务器与定制化 # 嵌入式Servlet容器切换与定制化 ## 切换Web服务器 ### 1. 原理 Spring Boot默认使用Tomcat作为嵌入式Servlet容器。切换其他容器#xff08;如Jetty或Undertow#xff09;的原理如下#xff1a; #### 自动配置类 - ServletWeb… 58、嵌入式Servlet容器切换web服务器与定制化 # 嵌入式Servlet容器切换与定制化 ## 切换Web服务器 ### 1. 原理 Spring Boot默认使用Tomcat作为嵌入式Servlet容器。切换其他容器如Jetty或Undertow的原理如下 #### 自动配置类 - ServletWebServerFactoryAutoConfiguration是关键的自动配置类负责创建ServletWebServerFactory。 #### 条件判断 - 根据项目中引入的依赖自动配置类会判断系统中存在哪些Web服务器相关的类。 #### 工厂类 - Spring Boot提供了多个ServletWebServerFactory实现 - TomcatServletWebServerFactory - JettyServletWebServerFactory - UndertowServletWebServerFactory - 根据条件判断选择相应的工厂类创建对应的Web服务器。 ### 2. 切换步骤 #### 排除默认Tomcat依赖 在pom.xml中排除spring-boot-starter-tomcat xml dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId exclusions exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /exclusion /exclusions /dependency #### 添加目标服务器依赖 - **切换为Jetty** xml dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jetty/artifactId /dependency - **切换为Undertow** xml dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-undertow/artifactId /dependency ### 3. 示例 #### 切换为Jetty xml dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId exclusions !-- 排除Tomcat -- exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /exclusion /exclusions /dependency !-- 引入Jetty -- dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jetty/artifactId /dependency 重新启动应用Spring Boot将使用Jetty作为嵌入式Servlet容器。 ## 定制嵌入式Servlet容器 ### 1. 通过配置文件 在application.properties或application.yml中配置服务器属性 properties # 修改端口 server.port8081 # 设置上下文路径 server.servlet.context-path/myapp # Tomcat特有配置 server.tomcat.uri-encodingUTF-8 ### 2. 实现定制器接口 实现WebServerFactoryCustomizer接口定制ServletWebServerFactory java Configuration public class CustomServletContainerConfig implements WebServerFactoryCustomizerConfigurableServletWebServerFactory { Override public void customize(ConfigurableServletWebServerFactory factory) { // 设置端口 factory.setPort(8082); // 设置访问日志 factory.setAccessLogEnabled(true); // 其他定制... } } ### 3. 示例 #### 定制Jetty容器 java Configuration public class JettyCustomizer implements WebServerFactoryCustomizerConfigurableServletWebServerFactory { Override public void customize(ConfigurableServletWebServerFactory factory) { if (factory instanceof JettyServletWebServerFactory) { JettyServletWebServerFactory jettyFactory (JettyServletWebServerFactory) factory; // 设置Jetty特有配置 jettyFactory.addServerCustomizers(server - { // 添加连接器配置 ServerConnector connector new ServerConnector(server); connector.setPort(8083); server.addConnector(connector); }); } } } 通过以上方式可以灵活地切换和定制Spring Boot的嵌入式Servlet容器满足不同的应用需求。
http://www.hkea.cn/news/14392742/

相关文章:

  • 网站建设流程有公众号网页版
  • 网站服务器是主机吗自己怎样在百度上做推广
  • 建站程序asp如何建设网站视频
  • 海口网站建设方案网站怎么做反爬虫
  • 周口城乡建设局网站漳州手机网站建设
  • 网站建设一般是用哪个软件wordpress 搭建教程
  • 网站维护收费标准女生学建筑工程技术就业前景
  • 行知智网站建设快速网站备案多少钱
  • 如何建立自己网站教程誓做中国最大钓鱼网站
  • 无锡网站设计多少钱怎么样销售关于网站建设
  • 山东建设人才网站wordpress手机上导航俩字
  • 杭州信贷网站制作行业网站建设公司
  • 德阳网站建设ghxhwl如何自建网站做外贸
  • 账号交易网站数据库应该怎么做东莞招聘网站
  • 网站开发学什么数据库龙岩到永定汽车时刻表
  • 做网站的设计理念上海中国建设银行网站
  • 2019年做网站还有机会吗自己做剧本网站
  • 学习做网站可以吗网站集约化建设情况
  • 微博问答网站开发看室内设计案例的网站
  • 青海网站建设推广怎么做网页会议邀请函
  • 池州市建设厅官方网站wordpress 开发文档
  • 企业网站建设600元翻译软件翻译英语做网站
  • 深圳网站建设 排行榜管理系统考生端重置密码
  • 齐齐哈尔铁峰建设局网站网站开发报价单明细
  • 微型营销网站制作wordpress导航栏做产品分类
  • 设计分公司加盟广州网站营销seo费用
  • 网站不备案不能访问吗虚拟机上做网站
  • 上海网站怎么备案表精准营销的成功案例
  • 网站建设包含什么怎么制作页面模板
  • qq空间网站是多少wordpress 注册邮箱验证码