diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml
index 87d2f612af..ea0acdcb00 100644
--- a/spring-mvc-java/pom.xml
+++ b/spring-mvc-java/pom.xml
@@ -19,6 +19,10 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
javax.servlet
javax.servlet-api
@@ -280,6 +284,7 @@
3.16-beta1
3.0.1-b09
+ com.baeldung.SpringMVCApplication
diff --git a/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java b/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java
index ee263aaab2..a456dc125e 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java
+++ b/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java
@@ -2,9 +2,10 @@ package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
-public class SpringMVCApplication {
+public class SpringMVCApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpringMVCApplication.class, args);
}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java b/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java
deleted file mode 100644
index eec12f466f..0000000000
--- a/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.baeldung.config;
-
-import org.springframework.web.WebApplicationInitializer;
-import org.springframework.web.context.ContextLoaderListener;
-import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
-import org.springframework.web.servlet.DispatcherServlet;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRegistration;
-
-public class AppInitializer implements WebApplicationInitializer {
-
- @Override
- public void onStartup(ServletContext container) throws ServletException {
- AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
-
- context.scan("com.baeldung");
-
- container.addListener(new ContextLoaderListener(context));
-
- ServletRegistration.Dynamic dispatcher = container.addServlet("mvc", new DispatcherServlet(context));
- dispatcher.setLoadOnStartup(1);
- dispatcher.addMapping("/");
-
- // final MultipartConfigElement multipartConfigElement = new
- // MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE,
- // MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2);
- //
- // appServlet.setMultipartConfig(multipartConfigElement);
- }
-
-}