传统的Servlet在spring boot中怎么实现的?
本文主要内容:
1:springboot一些介绍
2:传统的servlete项目在spring boot项目中怎么实现的?web.xml、url-patterns怎么设置?
3:有几种实现方式?分别是什么?
4:代码位置
spring boot 三大特性
组件自动装配:webMVC、webFlux、JDBC等
嵌入式Web容器:Tomcat、Jetty以及undertow
生产准备特性:指标、健康检查、外部化部署等
组件自动装配:
激活自动装配注解:@EnableAutoConfiguration
配置:/META-INF/spring.factories
实现:XXXAutoConfiguration.
我们以spring-boot-autoconfigure的jar下spring.factories为示例:
可以看到key是接口后没是实现。实现就是XXXAutoConfiguration.
嵌入式web 容器:
Web Servlet容器:Tomcat、Jetty以及undertow
Web Reactive容器:Netty Web Server
生产准备特性:
指标:/actuator/metrices
健康检查:/actuator/health
外部化配置:/actuator/configprops
Web应用:
传统的Servlet应用
Servlet组件:Servlet、Filter、listener
Servlet注册到spring boot中:Servlet注解、Spring Bean、RegistrationBean
异步非阻塞:异步Servlet(web 3.0特效)、非阻塞Servlet(servlet 3.1特性)。