Migrate from Spring MVC Restful Web Service to Spring Boot

Every single day technologies are changing and new frameworks are coming making developers lives easier. Migrating project framework is not easy and sometimes it does not depend just on the developers decision, but also teams decision or even maybe interdepartmental decisions. Spring MVC is a complete HTTP oriented MVC framework managed by the Spring Framework and based in Servlets. The most popular elements in it are classes annotated with @Controller, where you implement methods you can access using different HTTP requests. It has an equivalent @RestController to implement REST based APIs. Spring Boot is a framework used to set up applications quickly. It offers an out of the box configuration building Sprig powered applications. Spring boot already integrates a wide range of different modules as spring-core, spring-data, spring-web and so on. With this tool you can tell Spring how many of them to use and you'll get a fast setup for them. Spring boot is standalone and does not require any external server application e.g Tomcat, JBoss etc. Besides the external configuration this tool also offers another advantages like metrics, health checks among others. Spring boot is also a very easy compatible with Docker. The challenge is about migrating a simple Spring MVC Rest Service project to a Spring Boot project but keeping still WAR deployment. But why sill keep war deployment? Sometimes big changes like running the system in a application server and running the system in a standalone application server require few departments involved and lots of discussion about the topic. So, instead of changing drastically the system architecture the changes will be most likely done step by step.
1 answer

Do NOT forget to delete your web.xml and applicationContext.xml

Creating a war file in Spring Boot is not difficult.
It already supports by default 2 plugins for traditional deployment:
1.spring-boot-gradle-plugin
2.spring-boot-maven-plugin
The first step for the migration is to provide a SpringBootServletInitializer subclass and override its configure method. All of that is done in your @SpringBootApplication class.

The Second step is to set up you build file e.g. pom.xml, build.gradle, with the correct extension for the war file:
Maven: war
Gradle: apply plugin: 'war'

The Third step is to ensure that the embedded servlet container doesn’t interfere with the servlet container to which the war file will be deployed:
Maven:

org.springframework.boot
spring-boot-starter-tomcat
provided

Gradle: providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

The last but not least is to DELETE the current applicationContext.xml. If you keep the the context.xml the application will start and shutdown immediately, sometimes the error will be silent making it difficult to find the root cause.