org.springframework.boot.context.web

Class SpringBootServletInitializer

  • java.lang.Object
    • org.springframework.boot.context.web.SpringBootServletInitializer
  • All Implemented Interfaces:
    org.springframework.web.WebApplicationInitializer


    public abstract class SpringBootServletInitializer
    extends Object
    implements org.springframework.web.WebApplicationInitializer
    An opinionated WebApplicationInitializer to run a SpringApplication from a traditional WAR deployment. Binds Servlet, Filter and ServletContextInitializer beans from the application context to the servlet container.

    To configure the application either override the configure(SpringApplicationBuilder) method (calling SpringApplicationBuilder.sources(Object...)) or make the initializer itself a @Configuration. If you are using SpringBootServletInitializer in combination with other WebApplicationInitializers you might also want to add an @Ordered annotation to configure a specific startup order.

    Note that a WebApplicationInitializer is only needed if you are building a war file and deploying it. If you prefer to run an embedded container then you won't need this at all.

    Author:
    Dave Syer, Phillip Webb
    See Also:
    configure(SpringApplicationBuilder)
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
    • Constructor Detail

      • SpringBootServletInitializer

        public SpringBootServletInitializer()
    • Method Detail

      • onStartup

        public void onStartup(javax.servlet.ServletContext servletContext)
                       throws javax.servlet.ServletException
        Specified by:
        onStartup in interface org.springframework.web.WebApplicationInitializer
        Throws:
        javax.servlet.ServletException
      • createRootApplicationContext

        protected org.springframework.web.context.WebApplicationContext createRootApplicationContext(javax.servlet.ServletContext servletContext)
      • run

        protected org.springframework.web.context.WebApplicationContext run(SpringApplication application)
        Called to run a fully configured SpringApplication.
        Parameters:
        application - the application to run
        Returns:
        the WebApplicationContext
      • configure

        protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
        Configure the application. Normally all you would need to do it add sources (e.g. config classes) because other settings have sensible defaults. You might choose (for instance) to add default command line arguments, or set an active Spring profile.
        Parameters:
        application - a builder for the application context
        See Also:
        SpringApplicationBuilder

Copyright © 2014 Pivotal Software, Inc.. All rights reserved.