2

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?

Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110

1 Answers1

5

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/.

Dave Syer
  • 56,583
  • 10
  • 155
  • 143
  • I will have a look at the GAE sample later. I understand running on GAE implies that actuator might not be usable. – Marcel Overdijk Apr 10 '14 at 09:43
  • Are there plans to bring spring-boot-legacy to core spring-boot? – Marcel Overdijk Apr 10 '14 at 09:43
  • It would always be an add-on I think. It's definitely still a prototype at the minute, but I don't mind adding features and fixing bugs (pull requests, of course are welcome). Maybe we can have some more confidence that it works and covers all the bases if more people use it. – Dave Syer Apr 10 '14 at 09:48
  • Btw would it work by using AnnotationConfigWebApplicationContext in web.xml and just adding @ EnableAutoConfiguration to the @ Configuation class defined via contextConfigLocation? – Marcel Overdijk Apr 10 '14 at 10:18
  • Some things would work, but since you wouldn't be using `SpringApplication` to create the application context you wouldn't get the listeners and initializers, for instance. Some of that can be added back using `ApplicationContextInitializers` but it's probably better to stick with a custom `ContextLoaderListener`. – Dave Syer Apr 10 '14 at 10:24