Spring Boot是否支持servlet 2.5自动配置? [英] Does Spring Boot support servlet 2.5 auto-configuration?
问题描述
我想创建一个Spring Boot应用程序以部署在Google AppEngine基础架构上。 GAE目前仅支持servlet 2.5 web应用程序。
是否可以将Spring Boot(使用自动配置)与旧式web.xml结合使用?我可以使用contextClass / contextConfigLocation指向@Configration类,包括@EnableAutoConfiguration吗?
所有Spring Boot示例似乎使用一个简单的Application类和main方法来运行应用程序。所以我想知道Spring Boot是否支持使用web.xml作为起点来引导应用程序? 解决方案
超过在那里有一个问题:
-
没有什么能够阻止您使用web.xml(它仍然是Servlet规范的一部分)。现在大多数人更喜欢Java初始化工具。
使用Spring的特性)。 -
但是Spring Boot开箱即使没有
ContextLoaderListener
知道SpringApplication
,所以如果按照你的描述进行操作,你会错过Boot的一些好处。有一个你可能会觉得有用 here。 Spring Boot Actuator依赖于少量的Servlet 3.0特性,因此您需要2.5环境的解决方法详情请参阅 spring-boot-legacy原型)。
有一个示例应用此处运行目前部署在GAE上: http://dsyerboot.appspot.com/ 。
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?
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 aboutSpringApplication
, 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/.
这篇关于Spring Boot是否支持servlet 2.5自动配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!