How to register a servlet with enabled “async-supported” in Spring-Boot?

。_饼干妹妹 提交于 2019-12-24 11:23:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!