@WebServlet在内嵌容器不起作用吗,一定要用@ServletComponentScan吗?

来源:6-12 自定义 Resolver 实现

烟台果农

2018-08-29

写回答

1回答

小马哥

2018-08-29

是的,Spring Boot 嵌入式 Servlet 容器将默认的 Servlet 3.0 ServletContainerInitializer 特性取消了,因此只能通过这种方式实现。

请参考:https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/htmlsingle/#boot-features-embedded-container-context-initializer

Embedded servlet containers do not directly execute the Servlet 3.0+ javax.servlet.ServletContainerInitializer interface or Spring’sorg.springframework.web.WebApplicationInitializer interface. This is an intentional design decision intended to reduce the risk that third party libraries designed to run inside a war may break Spring Boot applications.

0
0

Spring Boot2.0深度实践 核心原理拆解+源码分析

系统化剖析Spring Boot 2.0,掌握技术原理,学习源码阅读技巧

2904 学习 · 213 问题

查看课程