To facilitate the deployment of a Spring Boot web application, simply include the following:
org.springframework.boot
spring-boot-maven-plugin
With this plugin, the package phase will generate a JAR file encompassing all essential libraries, dependencies, and even an embedded server. Consequently, the application can be effortlessly executed as a standard JAR file, ensuring seamless functionality.
Similarly, when aiming to construct a Web Application Archive(WAR) file, it is imperative to specify the packaging element within the project's configuration file. By including the war tag, you can indicate your intention to generate a WAR file successfully. This step is crucial for ensuring the proper deployment and functioning of your web application.
Spring Boot provides an embedded server to make JAR file deployment a simple matter; just build your application as a JAR file, which includes an embedded server (e.g., Tomcat) to run your web app, and use java -jar to open it up for execution.
To deploy as a WAR file, your project should be configured to create one instead of producing JARs. Change the Packaging element in Pom.xml from JAR to War and configure all relevant dependencies and servlet mappings as appropriate before uploading the WAR file onto Tomcat or Jetty for deployment.