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.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.