http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file describes precisely how to do it. Thanks for contributing an answer to Stack Overflow! Find centralized, trusted content and collaborate around the technologies you use most. Implementation: Project Demonstrating Spring WebApplicationInitializer. Before running the application add the below lines to the application-config.xml file. MyWebInitializer implements the WebApplicationInitializer one of the main advantages of using spring boot is the ability to easily set up your web applications with the built-in embedded tomcat. Share Improve this answer Follow answered Dec 13, 2016 at 20:12 Klaus Groenbaek 4,763 2 14 30 Thanks. injecting them into the DispatcherServlet. If we want to package it as a JAR file, then well need to add the same logic to the main() method so that the embedded container can pick it up as well. Here is some more information : How to deploy a spring boot MVC application in traditional tomcat webapps folder? The bootstrap code is in the onStartup method. Mit einem anerkannten Qualittsmanagement sorgen wir stets fr Ihre Zufriedenheit und eine hochwertige Ausbildung. However, when running this example, I receive the following error: Error:(11, 8) java: cannot access org.springframework.web.WebApplicationInitializer In the pom.xml file we have the following dependencies: logback-classic If your existing application has more than one programatically via Servlet context listeners. cannot access org.springframework.web.WebApplicationInitializer, https://spring.io/guides/gs/scheduling-tasks/, http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.boot/spring-boot/1.0.2.RELEASE/org/springframework/boot/context/web/SpringBootServletInitializer.java. We bind the application context with the Servlet context. Spring - Add User Name and Password in Spring Security. web application. Servlet 3.0+ applications might translate pretty easily if they already use the Spring Servlet 3.0+ initializer support How to check for #1 being either `d` or `h` with latex3? For example, there is SpringBootServletInitializer for Spring Boot applications. YouTube | Typically, you should update your applications main class to extendSpringBootServletInitializer, as shown in the following example: The next step is to update your build configuration such that your project produces a war file rather than a jar file. v override cu hnh web ti thi im ng dng c deploy. Mostly, developers use Xy dng ng dng Java Web Multi Module s - Kieu Trong a Spring web application. Let's develop complete step by step Spring Boot 2 Web application, generate a WAR file and deploy on external Tomcat server at, In this quick article, we will discuss the usage and importance of, org.springframework.boot.SpringApplication, org.springframework.boot.autoconfigure.SpringBootApplication, org.springframework.boot.builder.SpringApplicationBuilder, org.springframework.boot.web.servlet.support.SpringBootServletInitializer, Java Functional Interface Interview Q & A, org.springframework.boot.web.servlet.support package, http://www.javaguides.net/2018/09/spring-boot-deploy-war-file-to-external-tomcat.html, how to develop CRUD RESTFul API using Spring boot 2, Hibernate 5, JPA, Maven, and MySQL, SpringBootServletInitializer Class Official API Doc, https://www.udemy.com/user/ramesh-fadatare/, Spring Boot Restful Web Services Tutorial, Event-Driven Microservices using Spring Boot and Kafka, Spring Boot Kafka Real-World Project Tutorial, Building Microservices with Spring Boot and Spring Cloud, Building Real-Time REST APIs with Spring Boot, Testing Spring Boot Application with JUnit and Mockito, Spring Boot + Apache Kafka - The Quickstart Practical Guide, Spring Boot + RabbitMQ (Includes Event-Driven Microservices), Spring Boot Thymeleaf Real-Time Web Application - Blog App, void onStartup(ServletContext servletContext).