springboot中如何嵌入servlet容器以及容器启动过程

本文探讨了SpringBoot如何嵌入Servlet容器,如Tomcat、Jetty、Undertow,并重点讲解了默认如何排除Tomcat并引入其他容器。文章分为容器注入和使用两部分,详细阐述了ServletWebServerFactoryConfiguration配置类的角色以及SpringApplication.run方法在启动容器过程中的作用。
摘要由CSDN通过智能技术生成

  最近在学习springboot,抽空记录一下,加强记忆。

springboot兼容Tomcat,jetty,undertow容器,默认兼容Tomcat容器,因为spring-boot-starter-web包含tomcat,因此需要使用的时候,需要先把tomcat排除,再引入其他容器,如下:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<groupId>org.springframework.boot</groupId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<artifactId>spring-boot-starter-jetty</artifactId>
	<groupId>org.springframework.boot</groupId>
</dependency>

 现在分成2部分,容器注入方式和容器使用

  1. ServletWebServerFactoryConfiguration是配置类,里面的@Bean会被自动注入到spring容器中,通过@ConditionalOnClass来判断应该注入哪个servlet容器
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值