Does Spring Boot support servlet 2.5 auto-configuration?

故事扮演 提交于 2019-12-10 10:36:01

问题


I would like to create a Spring Boot application to be deployed on Google AppEngine infrastructure. GAE currently only supports servlet 2.5 web applications.

Is it possible to use Spring Boot - using auto-configuration - in combination with a old-fashioned web.xml?

Can I for example use a contextClass/contextConfigLocation pointing to a @Configration class including @EnableAutoConfiguration?

All Spring Boot examples seem to use a simple Application class with main method to run the application. So I would like to know if Spring Boot supports using a web.xml as start point to boot the application?


回答1:


More than one question there:

  • There's nothing stopping you from using web.xml (it's still part of the Servlet spec). Most people prefer the Java initializers these days.

  • @EnableAutoConfiguration works for any application context (it just uses features of Spring).

  • But Spring Boot out of the box doesn't have a ContextLoaderListener that knows about SpringApplication, so you miss some of the benefits of Boot if you do as you describe. There's one you might find useful here.

  • Spring Boot Actuator relies on a few Servlet 3.0 features here and there so you need workarounds for a 2.5 environment (see this spring-boot-legacy prototype for details).

There's a sample app here that runs on GAE, currently deployed here: http://dsyerboot.appspot.com/.



来源:https://stackoverflow.com/questions/22974475/does-spring-boot-support-servlet-2-5-auto-configuration

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