Spring Boot: SpringBootServletInitializer is deprecated

JavaSpring Boot

Java Problem Overview

I am trying to deploy Spring Boot app to JBoss by following this. It worked well but SpringBootServletInitializer is deprecated in 1.4.0.RELEASE. Which one should I use?

Maven depedency


Java Code

 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.web.SpringBootServletInitializer;

    public class DemoApplication  extends SpringBootServletInitializer {
    	public static void main(String[] args) {
    		SpringApplication.run(DemoApplication.class, args);

Java Solutions

Solution 1 - Java

You are using org.springframework.boot.context.web.SpringBootServletInitializer this is deprecated. Instead:



For SpringBoot 2.0


Solution 2 - Java

You can try this - worked for me

import org.springframework.boot.web.servlet.ServletContextInitializer;


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAung Myat HeinView Question on Stackoverflow
Solution 1 - JavaA0__oNView Answer on Stackoverflow
Solution 2 - JavapradeepView Answer on Stackoverflow