Cannot find ServletContextInitializer

Cannot find ServletContextInitializer

springIf you are upgrading to Spring Boot 1.5, you may notice that some classes, methods and properties were removed. One of them is ServletContextInitializer that was used to configure Java Servlet context. It was an interface and was available in Spring Boot 1.4 but it was marked as deprecated. It disappeared with the upgrade. See how it can be replaced.

 

Some of my projects had the following configuration:

@Configuration
public class WebConfiguration implements ServletContextInitializer {
    ...
}

A solution after upgrading to Spring Boot 1.5 is to replace the above usage of the interface with the code below.

@Configuration
public class WebConfiguration extends SpringBootServletInitializer {
    ...
}

As you can see previously ServletContextInitializer was an interface and it was replaced with SprintBootSerlvetInitializer which is a class.