问题
I'm planing to migrate my old app to Spring-Boot.
I want to stop using web.xml descriptor and register old pure Servlet ("async-supported" enabled) and an associated ServletContextListener.
回答1:
Spring Boot will automatically register any Servlet
beans in your application context with the servlet container. By default async supported is set to true
so there's nothing for you to do beyond creating a bean for your Servlet
.
If, for whatever reason, you want to take more control over your servlet's registration, then, rather than exposing the Servlet itself as a bean, you can wrap it in a ServletRegistrationBean
.
回答2:
Put a @EnableAsync on your application class. See here for more details.
来源:https://stackoverflow.com/questions/31720758/how-to-register-a-servlet-with-enabled-async-supported-in-spring-boot