This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.
Some people usually choose to follow this document to package the Spring Boot application to a jar file and use cli command to deploy the jar file to the app service with Java SE stack. However, you may also choose to package the Spring Boot project to a war file and deploy it to Tomcat. This article shows how you can do it.
Firstly, you need to modify your Spring Boot application entrance class to entend SpringBootServletInitializer class and override configure method:
You also need to make sure your project will be package to a war file. In Maven, it is specified in packaging element in the pom.xml:
If you are using Gradle, modify build.gradle as below:
You also need to have the following text in Maven to mark the embedded servlet container dependency as provided:
If you are using Gradle:
Then run "mvn clean" in the project folder or rebuild grade to generate the war file.
You can then create a web app and choose the same Tomcat version as the embedded one of your Spring Boot project. (Currently Tomcat 10 is not supported for Springboot yet).
Once it is created, run below command to deploy the war file to the app service: