|
1 | 1 | package org.baeldung.spring; |
2 | 2 |
|
| 3 | +import javax.servlet.ServletContext; |
| 4 | +import javax.servlet.ServletException; |
| 5 | + |
3 | 6 | import org.springframework.boot.SpringApplication; |
4 | 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
| 8 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 9 | +import org.springframework.boot.builder.SpringApplicationBuilder; |
| 10 | +import org.springframework.boot.web.support.SpringBootServletInitializer; |
5 | 11 | import org.springframework.context.annotation.Bean; |
6 | 12 | import org.springframework.context.annotation.ComponentScan; |
7 | 13 | import org.springframework.scheduling.annotation.EnableScheduling; |
| 14 | +import org.springframework.web.context.request.RequestContextListener; |
8 | 15 | import org.springframework.web.filter.ShallowEtagHeaderFilter; |
9 | | -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
10 | 16 |
|
11 | 17 | /** |
12 | 18 | * Main Application Class - uses Spring Boot. Just run this as a normal Java |
|
16 | 22 | @EnableScheduling |
17 | 23 | @EnableAutoConfiguration |
18 | 24 | @ComponentScan("org.baeldung") |
19 | | -public class Application extends WebMvcConfigurerAdapter { |
| 25 | +@SpringBootApplication |
| 26 | +public class Application extends SpringBootServletInitializer { |
| 27 | + |
| 28 | + @Override |
| 29 | + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
| 30 | + return application.sources(Application.class); |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public void onStartup(ServletContext sc) throws ServletException { |
| 35 | + // Manages the lifecycle of the root application context |
| 36 | + sc.addListener(new RequestContextListener()); |
| 37 | + } |
20 | 38 |
|
21 | 39 | public static void main(final String[] args) { |
22 | 40 | SpringApplication.run(Application.class, args); |
|
0 commit comments